Forum Moderators: open
<form name="form1">
<select name="form1Select" onChange="optionChange()">
<option selected value="noAction">The first one</option>
<option value="noAction">The second one</option>
<option value="noAction">The third one</option>
<option value="noAction">The fourth one</option>
<option value="noAction">The fifth one</option>
<option value="noAction">The sixth one</option>
<option value="noAction">The seventh one</option>
<option value="noAction">The eight one</option>
<option value="noAction">The ninth one</option>
<option value="noAction">The tenth one</option>
<option value="noAction">The eleventh one</option>
<option value="noAction">The twelfth one</option>
</select>
</form>
<script language="javascript">
<!--
function optionChange()
{
return false;
}
//-->
</script>
If you change the value of the selected element to something unique, then it works fine until you change the selection, once you refresh the page it will do the same thing... I'm at a loss.. Any help is much appreciated...
I'm looking at this with Mozilla 1.4.
-Jay
I just wanna say I've remember reading many of your pasts posts and they were very helpful...
That was just some skeleton JavaScript to make sure I had the option box working correctly.
I changed the first element name to something unique such as #noAction. The real option box had URL values and "#somethingToReflectNoChange" values. I added some script like this to deal with it....
function optionChange()
{
if (document.form1.form1Select[document.form1.form1Select.selectedIndex].value == "#noAction")// mozilla fix
{
// do something;
return false;
}
else if (document.form1.form1Select[document.form1.form1Select.selectedIndex].value == "noAction")
{
//do something;
return false;
}
else
location=document.form1.form1Select[document.form1.form1Select.selectedIndex].value;
}
I haven't tested it vigorously, but I think it stopped Mozilla from selecting a random option. However, like I said, I was just looking at it in Mozilla 1.4; it very well could have been fixed in a later version. Which brings me to the question of, what version of Mozilla should I test with? Other browsers? I can scan though the forums for this answer though...
You can let this one fade into oblivion, but if you can think of better approaches then I'm always interested...
Thanks again BlobFisk, your reply was appreciated.
It looks like you've left out options from your JS:
location=document.form1.form1Select.options[document.form1.form1Select.selectedIndex].value;
The correct (and full) code for getting a value from a select list is:
document.formName.selectName.options[document.formName.selectName.selectedIndex].valueOR document.formName.getElementById('selectID').options[document.formName.getElementById('selectID').selectedIndex].value
HTH