昨日何時間も遊んだ後、あなたの助けを求めることを考えました。この種の質問が以前に尋ねられたかどうかはわかりませんが、そこには何の助けも見つかりませんでした.
私は 4 つの依存ドロップダウンを持っており、ドロップダウンでsql
データベースからデータを取得しますchange
。では、 jQuerychange
は ID を php ファイルに渡し、ドロップダウン データを取得します。next
およびを使用しnextAll
て、依存するドロップダウンを更新します。
私の質問
ドロップダウンの周りに div を配置すると、データが読み込まれなくなります。.update
に変更し、他の100の方法を試しdiv .update
ましたが、どれもうまくいきませんでした。
マイコード
var formObject = {
run : function(obj) {
if (obj.val() === '') {
obj.nextAll('.update').html('<option value="">----</option>').attr('disabled', true);
} else {
var id = obj.attr('id');
var v = obj.val();
jQuery.getJSON('/pfi/mod/update.php', { id : id, value : v }, function(data) {
if (!data.error) {
obj.next('.update').html(data.list).removeAttr('disabled');
$('.findCar, .clearAll').fadeOut(); // hide Car button if more data available
} else {
obj.nextAll('.update').html('<option value="">----</option>').attr('disabled', true);
$('.findCar, .clearAll').fadeIn(); // show Car button
}
});
}
}
};
$(function() {
$('.update').live('change', function() {
formObject.run($(this));
$getCarInfoID = $(".update:not(:disabled)").last().val();
});
});
HTML ドロップダウン
<form action="" id="pfilterForm" method="post">
<div>
<select name="brand" id="brand" class="update">
<option value="">Select one</option>
<?php if (!empty($list)) { ?>
<?php foreach($list as $row) { ?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div><div>
<select name="make" id="make" class="update"
disabled="disabled">
<option value="">----</option>
</select>
</div><div>
<select name="series" id="series" class="update"
disabled="disabled">
<option value="">----</option>
</select>
</div><div>
<select name="model" id="model" class="update"
disabled="disabled">
<option value="">----</option>
</select>
</div>
<button name="data" type="button" class="findCar" onclick="getData()" style="display:none;" >GO</button>
<button name="data" type="button" class="clearAll" onclick="clearData()" style="display:none;" >Clear</button>
</form>
div
これをドロップダウンの周りで機能させるにはどうすればよいですか? このチュートリアルを使用して、ここまで取得しました。