Pass a SELECT value to a Javascript function through the onchange event?

I have an HTML page containing a search box containing several text fields.

The first part of the search box is the SELECT drop-down list , which contains many types of reports. Each type of report needs to fill out 1 or more text fields to filter query results. My goal is to hide text fields that are not required by the current report type.

How to transfer the current selected value from SELECT to Javascript function via onchange event ?

<select name="report_type" onchange="hide();">
<option value="full_history">Full History</option>
<option value="partial_history">Partial History</option>            
</select>
+5
source share
2 answers
<select name="report_type" onchange="hide(this.value);">
<option value="full_history">Full History</option>
<option value="partial_history">Partial History</option>            
</select>

, .

+11
function f1()
{
var obj1= document.getElementById("img");
var obj2= document.getElementById("s1");
obj1.src=obj2.value;
}

Select Image:
    <select id="s1" onchange="f1()">
        <option value="img1.jpg">img1.jpg</option>
        <option value="img2.jpg">img2.jpg</option>
        <option value="img3.jpg">img3.jpg</option>
        <option value="img4.jpg">img4.jpg</option>

    </select> <br><br>
    <img id='img' src="img1.jpg" height="500" width="500">
0

All Articles