samedi 21 mars 2015

How to Change the values of Text fields on the change of option box value

Hiii Guys, I am working on a project which is using Spring MVC and Hibernate framework. My problem is that I am working on a Form and in the form a Option Box working. I want to change a text field value on change of option box value. I already Try this :-



<script type="text/javascript" >
$(document).ready(function(){
$("#venderid").change(function(){
$.getJSON("getVenderById.htm", {venderId: $(this).val()},
function(vender){
var data = JSON.parse(vender);
var mail = data.mail;
$("#mail").html(mail);
}
);
});
});

</script>


Vender.java



public class Vender {
private Integer venderid;
private String vendername;
private String email;
private String contact;
//Setters and getters
}


Controller:-



@RequestMapping(value = "/getVenderById.htm")
@ResponseBody
public ModelAndView getVender(@RequestParam("venderId") int vId){
ModelAndView mav = new ModelAndView();
mav.addObject("vender", venderDAO.findById(vId));
System.out.println("=========Ajax Calling============");
return mav;
}


Every thing is working fine but how to filled the textbox of e-mail according vender id . Is there any mistake in Callback function , or how to utilize the value of vender object. And one more thing on Apache server console window ========Ajax Calling======= printing means data is coming from the database. But how do i utilize it please help . And thanks in advance.


Aucun commentaire:

Enregistrer un commentaire