PDA

View Full Version : Navigating to another site from list selection


beautyfiend
06-30-2009, 12:55 AM
Hi,
I have a list of sites on my page and it should take you to the site you select from the menu. But it is not working at the moment.
Any help much appreciated!
Thanks

In the head-
<script type="text/javascript">
function go_somewhere() {
var URL = document.getElementbyId ("sitelist").value;
window.open(URL);
}
</script>

In the body-
<form id="myform" action="#">
&nbsp;&nbsp;Select a web site to visit:&nbsp;&nbsp;
<select id="sitelist" size=1 onchange="go_somewhere()">
<option value="">Go to....
<option value="http://www.yahoo.com">YAHOO
<option value="http://www.google.com">GOOGLE
<option value="http://www.bbc.com">BBC
<option value="http://www.tfl.com">TFL
</select>
</form>

yell0wdart
06-30-2009, 01:48 AM
Looks like your casing is off on getElementById().

document.getElementbyId ("sitelist")

Should be:

document.getElementById("sitelist")

beautyfiend
06-30-2009, 08:38 AM
Looks like your casing is off on getElementById().

document.getElementbyId ("sitelist")

Should be:

document.getElementById("sitelist")

Hi,
I changed that but it is still not working....

beautyfiend
06-30-2009, 08:41 AM
I missed off the 'var URL=' !
It's working now, thanks for helping.


<script type="text/javascript">
function go_somewhere() {
var URL =document.getElementById("sitelist").value;
window.open(URL);
}
</script>