Click to See Complete Forum and Search --> : document.selecter


hazel
09-03-2003, 07:56 AM
Below is a code which works fine. However I want to put more than one of these drop down menus on a page and it would appear that it only works with one script. Does anyone know of any way I can alter the script to take more than one drop down menu on a page please ?

<script language="javascript" type="text/javascript">
function go()
{
if (document.selecter.select1.options[document.selecter.select1.selectedIndex].value != "none")
{
location = document.selecter.select1.options[document.selecter.select1.selectedIndex].value
}
}
</script>

<script language="JavaScript" type="text/javascript">
document.write('<form name="selecter"><select name="select1">');

document.write('<option value="france.html">France</option>');
document.write('<option value="ireland.html">Ireland</option>');
document.write('<option value=""></option>');
document.write('<option value=""></option>');
document.write('<option value=""></option>');
document.write('</select>');
document.write('<input type="button" value="Go" onclick="go()">');
document.write('</form>');
</script>

requestcode
09-03-2003, 08:17 AM
Here is an example that uses the onchange event in the select tag to call the script. It passes the value of the option tag to the script when you click on it. You could use this for multiple dropdowns.
<html>
<head>
<title>Drop Down Test</title>
<script language="javascript">
function LinkUp(linkid)
{
location.href=linkid
}
</script>
</head>
<body bgcolor="lightblue" onload="document.DropDown.reset()">
<form name="DropDown">
<select name="DDlinks" onchange="LinkUp(this.options[this.selectedIndex].value)" >
<option selected>Select One
<option value="maxtext8.htm"> Page One</option>
<option value="newwin.htm"> Page Two</option>
<option value="open.htm"> Page Three</option>
</select>
</form>
</body>
</html>

hazel
09-03-2003, 08:31 AM
Thank you kind Sir for your reply. I must explain myself better. Please see www.baynut.freeserve.co.uk and the drop down for France goes to the france.html page and the same for Ireland. However the drop downs for Texas and New York both go to Ireland ! Another curious thing is that although this (sort of) works on the web, try it on my local drive and it does nothing :o) Just says error on page.

requestcode
09-03-2003, 01:09 PM
Have you tried my version? One thing to remember is that you need to name your other dropdowns with a different name in the <select> tag. If you don't then you will have problems. Not sure why it does not work on your hard drive, possibley the pages are not in the same directory as the page with the dropdown. Also, I tried the link you gave and got the message it could not find it.