这是我在这里发布的第一个问题。所以希望你不要介意我身边的任何不熟练行为。下面是我的代码,我希望在下拉菜单中选择选项时,它会显示相应的分区并隐藏另一个。无论如何,show-hide正在工作,但即使两个分区具有单独的ID(sort = 1和sort = 2),也只显示两个分区的一个id(sort = 0)。也就是说,两个部门只进行基于资历的排序。 我怎么解决这个问题?我是这个领域的初学者,所以希望你能帮助我。提前谢谢。
<script type="text/javascript">
function ShowHideDiv() {
var ddlPassport = document.getElementById("ddlPassport");
var dvPassport = document.getElementById("dvPassport");
dvPassport.style.display = ddlPassport.value == "Y" ? "block" : "none";
var dvPass = document.getElementById("dvPass");
dvPass.style.display = ddlPassport.value == "N" ? "block" : "none";
}
</script>
<span>Sort Faculty List </span>
<select id = "ddlPassport" onchange = "ShowHideDiv()">
<option value="N">In Alphabetic order</option>
<option value="Y">Based On Seniority</option>
</select>
<hr />
<div id="dvPass" style="display: block">
<div style="margin:10px;">
<table id="faculty-list">
<thead>
<tr>
<th>S.No</th>
<th>Name</th>
<th>Designation</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<?php $dept_id=1;$sort=1;?>
</div>
</div>
<div id="dvPassport" style="display: none">
<div style="margin:10px;">
<table id="faculty-list">
<thead>
<tr>
<th>sl.No</th>
<th>Name</th>
<th>Designation</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<?php $dept_id=1;$sort=0;?>
</div>
</div>