I currently have two dropdown boxes and a textbox.
I am using a database query to fill the first dropdown box and ajax to fill the second dropdown, depending on the value chosen in the first dropdown. I also am using ajax to fill in the input textbox once a selection from the second dropdown is chosen.
My problem is, with my current code, when I choose an option from the first dropdown, although it DOES fill in the second dropdown box with the data returned from ajax, I also want it to ajax the input box as well and return that value at the same time as the second dropdown value updates.
$( "#manufacturerOpts" ).change(function(){
val1 = $(this).attr("value");
$.ajax({
url: "inc/class/data.php",
type: "POST",
data: "manu="+val1,
cache: false,
success: function (html1) {
$('#modelOpts').html(html1);
val2 = $("#modelOpts option").attr("value");
$.ajax({
url: "inc/class/data.php",
type: "POST",
data: "mod="+val2,
cache: false,
success: function (html2) {
$('#powerOpts').html(html2);
}
});
}
});
});
$( "#modelOpts" ).change(function(){
val1 = $(this).attr("value");
$.ajax({
url: "inc/class/data.php",
type: "POST",
data: "mod="+val1,
cache: false,
success: function (html1) { $('#powerOpts').attr("value",html1); }
});
// $("#modelOpts").selectmenu('refresh', true);
});