PDA

View Full Version : page redirecting with a select box


joonstar
05-20-2003, 08:34 AM
I like to make the page to go another page by selecting.

if a user selects "A", the page will go to A.php.
If a user selcts "B", the page will go to B.php.
If a user selcts "C", the page will go to C.php.

I made next code for that.

it doesn't work. but it show what is my intention.


<script language="javascript">

function go()
{
if (document.test.value == "1")
{
location.href = "A.htm;
}
else if (document.test.value == "2")
{
location.href = "B.htm";
}
else if (document.test.value == "3")
{
location.href = "C.htm";
}

}
</script>

<select name=test onchange="go()">>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">c</option>
</select>


Would you help me?

cheesebagpipe
05-20-2003, 09:40 AM
Glad to.

function go(selval)
{
if (selval == "1") location.href = "A.htm;
else if (selval == "2") location.href = "B.htm";
else if (selval == "3") location.href = "C.htm";
}

</script>

<select name=test onchange="go(options[selectedIndex].value)">
<option value="1">A</option>
<option value="2">B</option>
<option value="3">c</option>
</select>

Spudhead
05-20-2003, 10:09 AM
or....


function thingy(wotsit){
location.href = wotsit;
}


<select name="doofer" onChange="thingy(this.options[this.selectedIndex].value)">
<option value="a.htm">A</option>
<option value="b.htm">A</option>
<option value="c.htm">A</option>
</select>