Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

how to disable input form when select change

<select id="menu">
    <option value="0">News</option>
    <option value="1">Friends</option>
    <option value="2">Other</option>
</select>

<input id="comment" type="text" disabled="true" />

<script>
  document.getElementById('menu').addEventListener('change', function() {
    if (this.value == 2) {
        document.getElementById('comment').disabled = false;
    } else {
        document.getElementById('comment').disabled = true;
    }
});
</script>
Source by jsfiddle.net #
 
PREVIOUS NEXT
Tagged: #disable #input #form #select #change
ADD COMMENT
Topic
Name
4+1 =