如何根據下拉選項啓用/禁用輸入字段。而且我也應該根據選擇採用JSP中的用戶數據。如何根據HTML/JavaScript中的選擇值顯示錶單輸入字段?
<form action="../jsp/findActorbyChar.jsp">
<h3>Search by:
<select name ="nameField"> </h3>
<option> Only FirstName </option>
<option> Only LastName </option>
<option> Or </option>
<option> And </option>
</select>
<br><br>
First Name <input type="text" name="firstName"/>
Last Name <input type="text" name="lastName"/>
<br><br>
<input type="submit"/>
<input type="reset"/>
你嘗試過這麼遠嗎? –
通過使用窗體ID; var form = document.getElementById('id'); nameField = form.elements.nameField; nameField.onchange = function(){} – Suhas