171
rated 0 times
[
173]
[
2]
/ answers: 1 / hits: 116567
/ 11 Years ago, tue, april 9, 2013, 12:00:00
function CascadeDropDowns(parentClass, childClass, action, callback) {
var DropDownId = $(parentClass + option:selected).val();
$.ajax({
url: /site/ + action,
data: { DropDownId: DropDownId },
dataType: json,
type: POST,
error: function () {
alert(An error occurred.);
},
success: function (data) {
var items = ;
$.each(data, function (i, item) {
items += <option value= + item.Value + > + item.Text + </option>;
});
$(childClass).html(items);
$(childClass)[0].selectedIndex = 0;
callback();
}
});
}
$(document).ready(function () {
// Populates all child drop downs on load
var callback = function () {
CascadeDropDowns(.ConfigGroupDDL, .ConfigNameDDL, GetParameters);
};
CascadeDropDowns(.DeviceTypeDDL, .ConfigGroupDDL, GetGroups, callback);
// Populates all child drop downs parent change
$(.DeviceTypeDDL).change(function () {
var callback = function () {
CascadeDropDowns(.ConfigGroupDDL, .ConfigNameDDL, GetParameters);
};
CascadeDropDowns(.DeviceTypeDDL, .ConfigGroupDDL, GetGroups, callback);
});
$(.ConfigGroupDDL).change(function () {
CascadeDropDowns(.ConfigGroupDDL, .ConfigNameDDL, GetParameters);
});
});
This runs fine and cascades the dropdowns in the right order, but firefox debugger shows an error and ie throws an alert and asks if Id liek to debug.
Any advice would be great
More From » javascript