[Solved] show DIV once selected option PASS from drop down menu [closed]


Change the order

<select id="test" name="test" onChange="changetextbox();">
    <option value="PASS">PASS</option>
    <option>No</option>
    <option>No, but planning in future</option>
</select>

<input type="text" name="test" id="sdd" />

<script type="text/javascript">
document.getElementById('mfi_4_a_i').onchange = function(){
    if (this.value == 'PASS') {
        document.getElementById('sdd').style.display = "block";
    } else {
        document.getELementById('sdd').style.display = "none";
    }
};
</script>

You need to ensure that when the JavaScript runs the DOM elements are ready ….

Note your id attributes do not match either ..mfi_4_a_i in JavaScript vs test in HTML and you should either write a function changetextbox or write getElementById('blah').onchange = function() { not both …

<select id="test" name="test">
    <option value="PASS">PASS</option>
    <option>No</option>
    <option>No, but planning in future</option>
</select>

<input type="text" name="test" id="sdd" />

<script type="text/javascript">
document.getElementById('test').onchange = function(){
    if (this.value == 'PASS') {
        document.getElementById('sdd').style.display = "block";
    } else {
        document.getElementById('sdd').style.display = "none";
    }
};
</script>

Working example here

Another Note you had

document.getELementById('sdd').style.display = "none";

this should be

document.getElementById('sdd').style.display = "none";

I changed the case of the L in Element

2

solved show DIV once selected option PASS from drop down menu [closed]