現在、2つのドロップダウンボックスと1つのテキストボックスがあります。
最初のドロップダウンで選択した値に応じて、データベースクエリを使用して最初のドロップダウンボックスに入力し、ajaxを使用して2番目のドロップダウンに入力しています。また、2番目のドロップダウンからの選択が選択されたら、ajaxを使用して入力テキストボックスに入力しています。
私の問題は、現在のコードでは、最初のドロップダウンからオプションを選択すると、2番目のドロップダウンボックスにajaxから返されたデータが入力されますが、入力ボックスもajaxしてその値を返すようにすることです。 2番目のドロップダウン値が更新されると同時に。
$( "#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);
});