如何禁用選擇「pelajaran」 WHERE條件選擇jabatan =「經營者」如何與條件價值禁用選擇從數據庫
<select name="id_jabatan" id="jabatan" size="1" class="form-control" required>
<option label="-- Pilih Jabatan --"></option>
<?php //query untuk looping jabatan
$sql = "SELECT * FROM tb_jabatan_guru";
$result = $koneksi->query($sql);
while ($row = $result->fetch_array()){ ?>
<option value="<?php echo $row['idJabatan'] ?>"><?php echo $row['namaJabatan']; ?></option>
<?php } ?>
</select>
<select name="id_pel" id="pelajaran" size="1" class="form-control" disabled required>
<option label="-- Pilih Pelajaran --"></option>
<?php //query untuk looping pelajaran
$sql = "SELECT * FROM tb_pelajaran";
$result = $koneksi->query($sql);
while ($row = $result->fetch_array()){ ?>
<option value="<?php echo $row['idPelajaran'] ?>"><?php echo $row['namaPelajaran']; ?></option>
<?php } ?>
</select>
<script>
document.getElementById('jabatan').onchange = function() {
document.getElementById("pelajaran").disabled = this.value == 'Operator';
}
</script>
正在加載頁面時右邊? (不是動態選擇的) –
代碼應該在問題中 - 而不是外部資源(例如Pastebin)......如果Pastebin消失會發生什麼? – CD001
你寫的JavaScript代碼看起來應該做你想要的嗎?問題是什麼? –