i have two dropdown list.
first drop down:1
enter code here
<form:select path="custName" id="custName">
<form:option value="walk_in">Walk In</form:option>
<c:forEach var="led" items="${name}">
<form:option value="${led.ledName}">${ledger.ledName}</form:option>
</c:forEach>
</form:select>
second dropdwon :
<form:select path="customerName" id="c01">
<option value="walk_in">Walk In</option>
<c:forEach var="led" items="${name}">
<form:option value="${led}">
</form:option>
</c:forEach>
</form:select>
I have the following Spring Controller
@Controller
@RequestMapping("/accreq")
with the following mapping
@RequestMapping(value="/creditAccount_name.htm",method=RequestMethod.GET)
public @ResponseBody String GetName(@RequestParam(value="credit",required=true)String customername, ModelMap model){
List<Journal> journals=journalDao.getReceiptTypeName(customername);
System.out.println(customername);
String ID = journals.get(0).getJournalId().toString();
System.out.println(ID);
return ID;//here i am getting the value in console
}
I’m trying to call this method with the following jquery ajax
function getAjaxReceipt(){
var custname=$("#custName").val();
if(custname!="walk_in"){
$.ajax({
type:'GET',
url:'creditAccount_name.htm',
data:{credit:custname},
success:function(data){
$('#c01').val(data);//this is the feild id of second drop down value should display here...but is show empty...
alert(data);//here also i am getting the alertbox in jsp
},
error:function(xmlHttpRequest, textStatus, errorThrown){
if(xmlHttpRequest.readyState=0 || xmlHttpRequest.status == 0)
return;
},
});
}
The Scenario is i am getting the value of first dropdwon through query and binding it in controller.when i select the value of the first dropdown ,its corresponding value should bind in 2nd drop down.
for that i have used ajax and jquery…i am successfully get the value to the controller and passing the valuing to ajax..But the problem is the value is not binding in the dropdown box.
Can any one tell me what might have gone wrong?
The prblem is after the value is displayed in alert…its not showing in second dropdown.?
i am seeing in the second drop down like
<form:option value="${led}"></form:option>. You are having the value for that drop down but there is not display label set for that, but for the first drop down you have like<form:option value="${led.ledName}">${ledger.ledrName}</form:option>. Is that something properly done but you are not displaying it right?