• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to make this work in IE?

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should work. What is happening?
 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
um, how about ONCHANGE in the select element. You can not by event handlers in the option tags.

Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic