Novicane All American 15416 Posts user info edit post |
I wanted a drop list, when the users picked an item, it automatically went to it instead of having hit a button. I found a script that worked:
<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>Quick Select</option> <option value="prod1.php">product 4/option> <option value="prod2.php">product 3</option> <option value="prod3.php">product 3</option> </select>
but it only works in IE. When i select an item in safari/firefox it doesn't work. any help is appreciated on making this work across browsers.4/7/2009 1:48:18 PM |
kiljadn All American 44690 Posts user info edit post |
nmind you wanted a list
[Edited on April 7, 2009 at 2:06 PM. Reason : .] 4/7/2009 2:06:11 PM |
RSXTypeS Suspended 12280 Posts user info edit post |
^^aren't you missing the form tags so you can reference it with...
document.formName.elementName 4/7/2009 2:24:25 PM |
agentlion All American 13936 Posts user info edit post |
can probably look through the source of TWW and just do what it does 4/7/2009 2:33:37 PM |
RSXTypeS Suspended 12280 Posts user info edit post |
if i'm understanding what you want to do right all you have to do is...
window.location = document.formName.formElementName.value
and that will work in all browsers. 4/7/2009 2:34:59 PM |
Novicane All American 15416 Posts user info edit post |
did away with the function and just used it within the form code. This worked for me:
<form name="f2"> <select name="NavSelect" onChange="window.location=document.f2.NavSelect.options[document.f2.NavSelect.selectedIndex].value"> ..
4/7/2009 2:51:55 PM |
RSXTypeS Suspended 12280 Posts user info edit post |
^you don't need the .options.etc.etc
when you select an option in the drop down the value of the dropdown becomes the value of the option.
so document.f2.NavSelect.value would work too. 4/7/2009 2:55:19 PM |