我在列表中有两个选项(拾取/放下),我想要的是当用户从列表中选择拾取时(拾取日期/拾取时间)字段出现并且(放置日期/放置时间)字段被隐藏,反之亦然。
<html>
<script>
function hideDiv()
{
document.getElementById("div1").style.display='none';
document.getElementById("div2").style.display='block';
}
function showDiv()
{
document.getElementById("div1").style.display='block';
document.getElementById("div2").style.display='none';
}
</script>
<body onload="hideDiv()">
<form method = "post">
<H1>Please enter the following details below.</H1>
<table border="1" align="left" cellpadding ="30" cellspacing="5">
<tr>
<td align="left">
Employid <input type="text" name="sid" />
Supervisor <input type="text" name="ssup" />
Department <input type="text" name="sdept" />
<label>Select your option</label>
<select id="myList">
<option value="1" onselect="showDiv() name="pp">Pickup</option>
<option value="2" onselect="hideDiv()name="dd">Drop</option>
</select>
<div id="div2">
Pickup date <input type="date" name="pte" />
Pickup time <input type="time" name="ptm" /></br>
</div>
<div id="div1">
Drop date <input type="date" name="dte" />
Drop time <input type="time" name="dtm" /></br>
</div>
<input type="submit" name="submit" value="submit" /></br>
</td>
</tr>
</table>
<table border="1" align="right" cellpadding ="30" cellspacing="2">
<tr>
<td align="left">
<a href="myprojectallrequest.jsp">View all requests</a></br>
<a href="myprojectallrequest.jsp">View pending requests</a>
</td>
</tr>
</table>
</form>
</body>
</html>