Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browser behavior differences

Status
Not open for further replies.

kook04

Programmer
Jun 26, 2001
58
US
I have a VERY simple piece of JavaScript code that works in FireFox, but for some reason, does not work in IE or Netscape.

Here is the code, I will describe the problem below...


<script type="text/javascript">
function processOp(opFieldName, textFieldName)
{
var operatorSelect = document.forms[0].elements[opFieldName];
var textField = document.forms[0].elements[textFieldName];
alert(operatorSelect.selectedIndex); //*****
var operator = operatorSelect.options[operatorSelect.selectedIndex].value;
alert("Operator: " + operator); //*****
if (operator == "<%= Operator.BETWEEN.toString() %>")
{
textField.disabled=false;
}
else
{
textField.value="";
textField.disabled=true;
}
}
</script>

You can see where I added some debug output (indicated by trailing comments).

I am passing in the name of a text field and a select menu. The text field is supposed to be disabled/enabled based on the value in the select menu. This function is called when the select menu changes (onchange).

In IE and Netscape, the value of the "currently selected index" is always blank. However, the selected index number is correct, so I know that it is looking in the right spot.

In FireFox, everything works perfect.

Any ideas? Let me know if I didn't state the problem clear enough. Thanks everyone.

------
KJR
 
make sure your options have values;

Code:
<select name="blahSelect">
  <option [red]value="something 1"[/red]>Option 1</option>
  <option [red]value="something 2"[/red]>Option 2</option>
  <option [red]value="something 3"[/red]>Option 3</option>
</select>

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
That was the solution! Thank you very much.

------
KJR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top