Hi all I am a newbie in web programming so please help me out in this problem. I am trying to make 2 drop down lists linked together which I got from another forum and then I am trying to link the go button to another webpage according to option selected. For going to another page i got the function but when I am trying to link it is not working
Here is the code.There are two functions 1. for linking drop down lists 2. for going to another page. but it is not working as i have written the onClick function go to a new page.
<html>
<head>
<script type="text/javascript">
function setOptions(chosen) {
var selbox = document.myform.opttwo;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
}
if (chosen == "1") {
selbox.options[selbox.options.length] = new
Option('http://www.google.com','oneone');
selbox.options[selbox.options.length] = new
Option('first choice - option two','onetwo');
}
if (chosen == "2") {
selbox.options[selbox.options.length] = new
Option('second choice - option one','twoone');
selbox.options[selbox.options.length] = new
Option('second choice - option two','twotwo');
}
if (chosen == "3") {
selbox.options[selbox.options.length] = new
Option('third choice - option one','threeone');
selbox.options[selbox.options.length] = new
Option('third choice - option two','threetwo');
}
}
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
function JumpToIt(frm) {
var newPage = frm.url.options[frm.url.selectedIndex].value
if (newPage != "None") {
location.href=newPage
}
}
//-->
</SCRIPT>
</head>
<form name="myform"><div align="center">
<select name="optone" size="1"
onchange="setOptions(document.myform.optone.options
[document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected"> </option>
<option value="1">First Choice</option>
<option value="2">Second Choice</option>
<option value="3">Third Choice</option>
</select><br> <br>
<select name="opttwo" size="1">
<option value=" " selected="selected">Please select one of the options above first</option>
</select>
<INPUT TYPE=BUTTON VALUE="Go!" onClick="JumpToIt(this.myform)">
</div></form>
</html>
so someone please tell me what should i write in the onclick function so that it will go to the linked page.
1 Answer