I have a HUGE form concerning employee attributes with like 300 fields.
When the admin wants to edit employee attributes, they go to the edit page. This form is printed dynamically from the database.
The user selects an employee from a dropdown lets call it dropdown1. The form is then populated from a JSON array using a jquery ajax call bound to the change event of dropdown1. This way 299 fields are correctly populated.
However, the form contains 2 more dropdowns. Lets call them dropdown2 and dropdown3.
Dropdown2 is populated on page load from the database.
Dropdown3 is related to dropdown2. When dropdown2 changes, the listings of dropdown3 change using a DIFFERENT onchange ajax function. Initially, on page load dropdown3 has only one listing "select".
My problem is when dropdown1 changes, every field in the form is populated except dropdown 3.
What I want is, when the selection changes in dropdown2 using the jquery ajax call,
The dropdown3 should be populated according to the value in dropdown2 - Basically the html of the div containing dropdown2 should change (An ajax call inside another ajax call ?)
the correct value should be selected in dropdown2 (if 1 works I think I could handle this part)
I apologize if my question is very lengthy and I haven't been able to explain properly.
$(document).ready(function(){
$("#adminobj0zb").delegate("#sel10", "change", function(e){
$.getJSON("editempajax2.php?empid=" + $("#sel10").val(),
function(data){
$.each(data, function(i, item){
if(item.field == "fname"){
$("#sel2").val(item.value);
//Here Make Second Ajax call and change content of div containing sel3 ... how ?
}
if(item.field == "mname"){
$("#sel3").val(item.value);
}
});
});
});
});