troubleshooting Question

Dropdown disable not working in JQuery or Javascript

Avatar of IKtech
IKtech asked on
6 Comments1 Solution1699 ViewsLast Modified:
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';

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.
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros