Click to See Complete Forum and Search --> : Having trouble with form values...


kj2w
01-06-2003, 12:12 PM
I wanna do a window.open when a certain <option> is selected in my select tag. It works in ie, but not nn 4.X, can you tell me why?

HTML:
<form action="Insert.cfm" method="post" id="myForm" onSubmit='return verify(this);'>

<select name="GroupDes" onChange="addNewGroup(this);">
<option value="blank" selected></option>
<option value="1">--- Add New Category ---</option>
</select>

</form>

JAVASCRIPT:
function addNewGroup(m){
if(document.myForm.GroupDes.value == '1'){
alert("hello");
}
}

gil davis
01-06-2003, 12:45 PM
Originally posted by kj2w
It works in ie, but not nn 4.X, can you tell me why?
Yep! Common mistake.

if(document.myForm.GroupDes.value == '1'){

You used an IE only short cut. You need to use the "long version". Change it to:

if(document.myForm.GroupDes.options[document.myuForm.GroupDes.selectedIndex]value == '1'){

Works in both browsers.

kj2w
01-07-2003, 08:08 AM
Thanks for the reply.


:D