Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Congratulations on a brilliant idea and a great site..."

Geography

Where in the world do Tek-Tips members come from?

disabling 'select' menu not working on IE

ag1060 (Programmer)
11 Jul 12 19:34
Hello coders,

I have this small javascript code that works fine in chrome/firefox but won't disable the 'select' menu in IE...any suggestion? Thank you in advance.

CODE

<label>
Gender<br>
 <select name="gender" id="gender" onclick="if (this.checked) document.getElementById('org').disabled=true; else document.getElementById('org').disabled = false;" />
    <option selected>Male</option>
    <option>Female</option>
  </select></label>
<br><br><label>
<input type="checkbox" id="org" name="org" onclick="if (this.checked) document.getElementById('gender').disabled=true; else document.getElementById('gender').disabled = false;"  /></label>
This account is for an oganization / company.<br><br> 
feherke (Programmer)
12 Jul 12 5:26
Hi

Better tell us your goal. For now your code is quite confusing for me, and I am sure as visitor I would find its behavior confusing too.
  • select elements have no checked property.
  • Disabling two controls on each others events usually breaks some functionality.
Just as a matter of readability

CODE --> JavaScript

// instead of this
if (this.checked) document.getElementById('gender').disabled=true; else document.getElementById('gender').disabled = false;

// personally I prefer this
document.getElementById('gender').disabled=this.checked 

Feherke.
http://feherke.github.com/

ag1060 (Programmer)
12 Jul 12 15:37
Hello,

Thanks for the reply. I have added your code and works fine (except on IE 9). Here's what I was trying to do:

http://oi49.tinypic.com/6s4djp.jpg

Basically it just disables if the menu if marked. I just want to make it work on IE9. I also use PHP to reinforce it but still nice to have the JS working on IE9.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close