Forum Moderators: open
What I want to do is the following, I have a list of months in a drop down
When someone changes the month I want to refresh the page with a querystring relating to the value they just selected.
At the moment the code is like this:
<form name="formTest" action="test.asp" >
<select name="month">
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
</select>
</form>
I know I have to use OnChange in the select bit but don't know how to make it so it opens the page /test.asp?month=7 if someone selects July.
<FORM method="GET" name="testForm" action="test.asp" >
<SELECT name="month" onChange="this.form.submit();">
<OPTION value="6">June</OPTION>
<OPTION value="7">July</OPTION>
<OPTION value="8">August</OPTION>
</SELECT>
</FORM>
If you want to set an option to selected using JavaScript, you'll need to:
1) parse the query-string to get the value of "month"; then
2) set document.testForm.months.selectedIndex to the item you want selected (index starts at 0).