• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make this work in IE?  RSS feed

 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a selection box like this:



I want to retrieve the level value based on an event

This works on Firefox:
level=document.FormName.level.selectedIndex
alert(level);

or even

level=document.getElementById("level").value;
alert(level);

None of them work in IE. How can I make it work in IE?

Thanks million.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should work. What is happening?
 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,

I realize this portion of the code is not working in IE but works in Firefox:
<option value="1" onMouseDown="goAlert(1)">Level 1</option>

I want the click on the option to trigger goAlert(). Any workaround?

Thanks a lot.


This is the testing code:

<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function goAlert(level){
alert(level);
}
</script>
</head>

<body>
<form id="FormName" action="(EmptyReference!)" method="get" name="FormName">
<table width="495" border="0" cellspacing="0" cellpadding="2" bgcolor="white">

<tr>
<td bgcolor="#d0eaf6" width="95">
<div align="right">
<p style="font-family: verdana; font-size: 10px"><b>* Level:</b></p>
</div>
</td>
<td bgcolor="#d0eaf6" width="150">
<select name="level" id="level" size="1">
<option value="">Select</option>
<option value="1" onMouseDown="goAlert(1)">Level 1</option>
<option value="2" onMouseDown="goAlert(2)">Level 2</option>
<option value="3" onMouseDown="goAlert(3)">Level 3</option>
<option value="4" onMouseDown="goAlert(4)">Level 4</option>

</select></td>
</tr>


<tr>
<td colspan="2" bgcolor="#d0eaf6" width="487">
<div align="center">
<input type="submit" name="submitButtonName"/></div>
</td>
</tr>
</table>
</form>
</body>

</html>
</code>
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
um, how about ONCHANGE in the select element. You can not by event handlers in the option tags.

Eric
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!