I populate child dropdown (second dropdown) by the onchange event in parent dropdown (first dropdown). After that by onchange event of child dropdown I am autofilling three
In auto.jsp
'#combo' change anonymous function, replace:
$.getJSON('combo1.jsp', {firstcombobox : this.value}, function(responseData) {
$("#combo1").append(
$("<option></option>").html(responseData.name).val(responseData.name)
);
});
with:
$.getJSON('combo1.jsp', {firstcombobox : this.value}, function(responseData) {
$("#combo1").empty().append(
$("<option></option>").html(responseData.name).val(responseData.name)
);
});
To split the string into an array look here: How do I split a string, breaking at a particular character?
They use as follows:
$.getJSON('combo1.jsp', {firstcombobox : this.value}, function(responseData) {
var splitValues = responseData.name.split(/,/);
$("#combo1").empty().append("<option value="0">Please select...</option>");
for (var idx in splitValues) {
$("#combo1").append(
$("<option></option>").html(splitValues[idx]).val(splitValues[idx])
);
}
});
Hope this helps?