<form>
<input type="text" id="name" onkeydown="myHandler()"/>
<select id="select">
<option value = "a">a</option>
<option value = "b">b</option>
</select>
</form>
<script>
function myHandler() {
if(document.getElementById("name")){
document.getElementById("select").disabled = true;
return;
}
document.getElementById("select").disabled = false;
}
</script>
Well, this is all I have done. This disables the select whenever I input something in input but the select will stay disabled even if erase all the inputs in the input box. What can I do to make the select selectable if the input field is empty?
select