Forum Moderators: open

Message Too Old, No Replies

Javascript Dropdown Menu

Javascript Dropdown Menu

         

TheAlbinoEthiopian

1:51 am on Feb 10, 2007 (gmt 0)

10+ Year Member



Yeah, I'm pretty sorry with javascript, this is the code I have right now.
<script language=JavaScript>
function Navigate() {
var number = NavSelect.selectedIndex;
location.href = NavSelect.options[number].value; }
</script>
<select name="NavSelect" onChange="Navigate(this.form)">
<option value="" SELECTED>Menu
<option value="http://www.google.com">Google</option>
</select>

For some reason it only works in Internet Explorer, the options are not clickable in Firefox. Anybody know what's wrong?

*EDIT*
Sorry, I got it.

[edited by: TheAlbinoEthiopian at 2:07 am (utc) on Feb. 10, 2007]

TheAlbinoEthiopian

2:02 am on Feb 10, 2007 (gmt 0)

10+ Year Member



By the way, I've been piecing together this from random articles on the net.

cmarshall

3:42 am on Feb 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I take it you know about this [w3.org]?

<option value="" selected="selected">Null</option>

Also, your JavaScript isn't OK.

You need to either pass in the element being used (Navigate(thisSelect){var number = thisSelect.selectedIndex}), or use an id, and do a document.getElementById(). I made this mistake all the time, and I think I'm finally learning.