SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Drop down listbox onChange

We can read the selected option of a drop down list box by using onChange event trigger. The onChange event will trigger one JavaScript function and we will try to read the selected item by using getElementById


Here is the code

<html>
<head>
<title>Demo Project on JavaScript listbox onChange</title>
</head>
<script type="text/javascript">
function show_date(){
document.getElementById("msg3").innerHTML= document.getElementById("s1").value;
return true;
}
</script>

</body>
<body>

<select id=s1 name=no_year onChange="show_date()";><option value=Jan>January</option>
<option value=Feb>February</option>
<option value=March>March</option>
<option value=April>April</option>
<option value=May>May</option>
</select>

<div id='msg3'></div>

</body>
</html>




Further readings
Disabling the submit button till all the elements of the form are validated
getElementById to access form elements with event handlers
Javascript Form Validation
Period button Validation of a form
How to limit number of checkboxes allowed to be clicked inside a form
Checkbox Validation of a form
Displaying checked value of a check box array
Enable or disable of a text box by a checkbox
All Checking & Un checking in a group of checkboxes by single button
Adding options to a drop down list box
Removing options from a drop down list box
Moving options from one drop down list box to other
Dynamic population of second list box based on value of first list box
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

Join Our Email List
Email:  
For Email Newsletters you can trust
Form validation