Dropdown disable not working in JQuery or Javascript

Posted on 2013-12-05
Last Modified: 2013-12-06
I have a JavaScript function that used to work until upgrading to IE 11.  It also doesn't work in either Chrome or FireFox.  

The dropdown is disabled by default, but enabled when a checkbox is changed.

As you can see from the code, I've tried removeAttribute, disabled = false, and finally JQuery.  None seems to be enabling the dropdown.  The alerts show the correct attributes, but in the source it still shows disabled='disabled'.

Any help would be greatly appreciated.

Here's the javascript/JQuery:

        function enableDropDownList(cb) {
            var chkbx = document.getElementById(cb);
            var number = cb.match(justTheDigits);
            var ddlname = "gvCylinderInfo_ctl" + number + "_ddlQtyReassign";
            var ddl = document.getElementById(ddlname);
            //ddl.setAttribute('disabled', 'disabled');
                    alert(ddl.disabled);  //This shows up as 'true'
            if (chkbx.checked) {
                $(ddl).each(function () {
                    this.disabled = false;
                    alert(ddl.disabled);  //This shows up as 'false' - just what I want.
                //ddl.disabled = false;
                document.getElementById('selectCylsPrompt').style.display = 'none';
                document.getElementById('chooseC').style.display = 'block';

            else {
                ddl.disabled = true;
                document.getElementById('selectCylsPrompt').style.display = 'block';
                document.getElementById('chooseC').style.display = 'none';


Open in new window

When I view source it shows:

<select name="ddlSystem" onchange="javascript:setTimeout(&#39;__doPostBack(\&#39;ddlSystem\&#39;,\&#39;\&#39;)&#39;, 0)" disabled="disabled" id="ddlSystem" class="arial8ptBlack">

Still disabled.

Any ideas?  Thanks.
Question by:IKtech
  • 3
  • 2
LVL 82

Accepted Solution

leakim971 earned 500 total points
Comment Utility
Test page :

I see : var ddlname = "gvCylinderInfo_ctl" + number + "_ddlQtyReassign";
By you dropdown ID is just : ddlSystem


Expert Comment

Comment Utility
In JS you must set a true/false boolean value, such as: document.getElementById("myDropdown").disabled=true/false.
Try then to replace disabled="disabled" with disabled="true".
LVL 82

Expert Comment

Comment Utility
@Sar1973 :
Without jQuery the RIGHT way is to use setAttribute() and removeAttribute()
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!


Expert Comment

Comment Utility
LVL 82

Expert Comment

Comment Utility

That will NOT work everytime
Be very careful with W3School resources

Author Closing Comment

Comment Utility
This was only part of it.  There were a few elements disabled.  I just needed to find all of them and do a removeAttribute.


Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question ( on how to make a page show some balloons animate up a page…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now