I know how to fill a single dropdown box with the values from a database using jQuery. But now i need to make a long query to filter out 5 table fields using dropdown. That is, by selecting the first , i need to change the remaining 4 dropdowns list value, and by changing the second dropdown, i need to change the other 3 dropddowns and so on. For changing a single dropdown, i made use of Ajax to send to a URL, and then returning the html and placing it inside the , select field.
jQuery.ajax({
type: "POST",
url: "getdb/tb",
data: '{data : "data" }',
success: function (data) {
jQuery("select#field_1").html(returnval);
},
failure: function (response) {
alert("failed");
}
});
And in my URL "getdb/tb" , i filter out the query using SELECT statement and echo out the option field.
But i dont know how to send multiple html option field to my 4 other dropdowns with a single change function carried in the first dropdown. Please help and treat me a beginner. Thanks in advance.
UPDATE : Is it a good way to do like this
jQuery.ajax({
-
-
success: function(data){
callfirst();
}
});
function callfirst(){
jQuery.ajax({
-
-
success: function(data){
callsecond();
}
});
}
function callsecond(){
jQuery.ajax({
-
-
success: function(data){
callthird();
}
}