Option onClick in Internet Explorer

  • trotsky
  • Born
  • Born
  • trotsky
  • Posts: 2

Post 3+ Months Ago

In a page that I am working on right now I have this problem:

I have a dropdown menu using select. This menu has two options. What I want to happen is that when I click the first option another dropdown menu (let us call it B), is disabled. And when I click the second option, menu B is enabled. I've tried to solve it this way:
Code: [ Select ]
<select name='Type'>
<option onClick='dm();' onSelect='dm();' value='DM'>Option 1</option>
<option onClick='rm();' onSelect='rm();' value='RM'>Option 2 </option>
</select>
  1. <select name='Type'>
  2. <option onClick='dm();' onSelect='dm();' value='DM'>Option 1</option>
  3. <option onClick='rm();' onSelect='rm();' value='RM'>Option 2 </option>
  4. </select>

(As you can see, I've defined both onClick and onSelect trying to make it work).

The javascript code is in a file called util.js. This is the code:
Code: [ Select ]
function dm(){
    alert("OK");
    document.newMalForm.menuB.disabled="disabled";
    return;
}

function rm(){
    alert("OK");
    document.newMalForm.menuB.disabled=false;
    return;
}
  1. function dm(){
  2.     alert("OK");
  3.     document.newMalForm.menuB.disabled="disabled";
  4.     return;
  5. }
  6. function rm(){
  7.     alert("OK");
  8.     document.newMalForm.menuB.disabled=false;
  9.     return;
  10. }


The javascript file is included using this tag:
Code: [ Select ]
<script type='text/javascript' src='util.js' language='JavaScript'></script>


Now, this works in firefox but not in IE. In fact, IE doesn't even run the functions as the alert (called in the javascript file) isn't shown when I click the menu options. What is the problem?

EDIT: The alert only exists in debug purpose. And I also wanted to say that this is my first post in this forum! :P

More editing, to clarify: newMalForm is the form that contains both of the dropdown menus.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Remove the events from the options, use an event directly on the select instead.

Internet Explorer treats select boxes slightly different than the rest of the document, (if you've ever read anyhting about "windowed controlls" you know what I'm talking about)

I'm thinking IE doesn't notice events in childnodes of select elements, only the select elements themselves.

I normally setup my functions to work depending on either of the selects value or selectedIndex attribute & using the onchange event.

Code: [ Select ]
function this(state){
var disState = state == 1;
alert(disState);
}

...

<select onchange="this(this.selectedIndex)">
 <option>Disabled</option>
 <option>Enabled</option>
</select>
  1. function this(state){
  2. var disState = state == 1;
  3. alert(disState);
  4. }
  5. ...
  6. <select onchange="this(this.selectedIndex)">
  7.  <option>Disabled</option>
  8.  <option>Enabled</option>
  9. </select>
  • trotsky
  • Born
  • Born
  • trotsky
  • Posts: 2

Post 3+ Months Ago

Thank you very much, now it works. You're quite right, IE handles things in a strange way, I've noticed.
  • djancak
  • Born
  • Born
  • djancak
  • Posts: 1

Post 3+ Months Ago

Quote:
Now, this works in firefox but not in IE. In fact, IE doesn't even run the functions as the alert (called in the javascript file) isn't shown when I click the menu options. What is the problem?

Hello from the year 2012! Internet Explorer 10 is now out and this problem is still not fixed! Bye!

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 63 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.