my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes How to make this work in IE? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to make this work in IE? " Watch "How to make this work in IE? " New topic
Author

How to make this work in IE?

Richard Vagner
Ranch Hand

Joined: Jun 26, 2001
Posts: 107
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

Joined: Jan 10, 2002
Posts: 60782
    
  65

Should work. What is happening?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Richard Vagner
Ranch Hand

Joined: Jun 26, 2001
Posts: 107
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
um, how about ONCHANGE in the select element. You can not by event handlers in the option tags.

Eric
 
jQuery in Action, 2nd edition
 
subject: How to make this work in IE?
 
Similar Threads
innerHTML with drop down box not working with IE
problem with multi select box with horizontal scroll bar
Firefox doesn't show background color for selected option
How to disable an option within select dropdown in IE
Script using array