FlatHead,
Here's a JavaScript function that will read the address from the option value (if you can spare it). This way, the function is re-usable for any select list. I have this function stored in an external .js file and call it from hundreds of select lists in my application. Looks like this.
Code:
function goApp(srcElement) {
if (srcElement.options[srcElement.selectedIndex].value != "") {
var address = srcElement.options[srcElement.selectedIndex].value
srcElement.options[0].selected = true
window.location.href = address
} else {
srcElement.options[0].selected = true
}
}
Here's what a select list looks like.
Code:
<select name="webList" onChange="goApp(this);">
<option value="">Select a Search Engine</option>
<option value="[URL unfurl="true"]www.yahoo.com">Yahoo</option>[/URL]
<option value="[URL unfurl="true"]www.msn.com">MSN</option>[/URL]
<option value="[URL unfurl="true"]www.google.com">Google</option>[/URL]
</select>
Now in my example I always have the first option say something like
Select Something with a value of nothing. The function is designed to ignore that, as well as it is designed to ignore anything else in the select list with a value of "". This way, you can put seperators in your select list that will be ignored. What's important is that the function will return the list back to the first option after the function is run. So you could have a list that looked like this.
Code:
<select name="webList" onChange="goApp(this);">
<option value="">Select a Web Site</option>
<option value="">-----------------</option>
<option value="">Sports Sites</option>
<option value="[URL unfurl="true"]www.espn.com">ESPN</option>[/URL]
<option value="[URL unfurl="true"]www.abcsports.com">ABC[/URL] Sports</option>
<option value="[URL unfurl="true"]www.mnf.com">Monday[/URL] Night Football</option>
<option value="">-----------------</option>
<option value="">Search Engines</option>
<option value="[URL unfurl="true"]www.yahoo.com">Yahoo</option>[/URL]
<option value="[URL unfurl="true"]www.msn.com">MSN</option>[/URL]
<option value="[URL unfurl="true"]www.google.com">Google</option>[/URL]
<option value="">-----------------</option>
</select>
The function works the same on any select list where you call the function in the
onChange event handler and have the URL in the option value. Don't forget to include the parameter
this in the function call. That way, no matter where the function is, or where the select list is put in your document, that passes the select list by reference to the function. Well I shouldn't really say that. The function needs to be on the current page or in a .js file referenced on the current page.
ToddWW