View Full Version : URL in select menu

10-27-2007, 12:23 PM

I have following code:

<select name="Networksites">
<option selected="selected">Network Websites</option>
<option value="http://www.testsite.com">Testsite.com</option>
<option value="http://www.testsite2.com">Testsite 2.com</option>

I want to be able to navigate to the sites when I select them in the menu, however nothing happens when I select them.

What have I done wrong? I found an old thread here, and its code looked similiar.

10-27-2007, 12:32 PM
<select name="Networksites" onchange="window.location=this.value;">
This will do it partially, but I'm not whether it suits or not since you may have to check this.value.
PS:Giving a button "GO to the selected" would be more friendly to users.

10-27-2007, 12:38 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function openSite(thisELE)
var index = thisELE.selectedIndex;

if(index > 0)
window.location = thisELE.options[index].value;

<select name="Networksites" onchange="openSite(this)">
<option selected="selected">- Select -</option>
<option value="http://www.testsite.com">Testsite1.com</option>
<option value="http://www.testsite.com">Testsite.com</option>
<option value="http://www.testsite2.com">Testsite 2.com</option>

gud luck

10-27-2007, 01:17 PM
Thanks, that worked!