We help IT Professionals succeed at work.

iterating through GridView and trying to figure out how to check if the check box controlled is enabled or not ??

brgdotnet
brgdotnet asked
on
106 Views
Last Modified: 2017-04-03
How can I check if my check box control is enabled or not? I have tried the following code check :
if(inputList[i].disabled) {  }

But it does not work, because there is not a "disabled" property for my check box control.

The GridView was created dynamically in asp.net but ultimately I need to be able to set the values using Java script. All the code below works great except I don't know how to check if the checkbox is enabled or not? My goal is to check the checkbox if it is indeed disabled.

function UncheckAll(objectRef)
{

  var row = objectRef.parentNode.parentNode;
  var GridView = row.parentNode;
  var inputList = GridView.getElementByTagName("input");
  

 for(var i = 0; i < inputList.length; i++)
  {
     if(inputList[i].type == "checkbox")
	{
          if(inputList[i].disabled) // .disabled is not a property, so how can I check if it is enabled or not?
          {

          }
	  
	}


  }


}

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
The checkbox element has an attr named "checked" So try with this change your  code.
function UncheckAll(objectRef)
{

  var row = objectRef.parentNode.parentNode;
  var GridView = row.parentNode;
  var inputList = GridView.getElementByTagName("input");
  

 for(var i = 0; i < inputList.length; i++)
  {
     if(inputList[i].type == "checkbox")
	{
//I changed the disabled property with the checked property
          if(inputList[i].checked===false) // .disabled is not a property, so how can I check if it is enabled or not?
          {

          }
	  
	}

Open in new window


PS
If it not working the above then set manual the attr checked in checkbox element and then retry to tun the code
brgdotnetcontractor

Author

Commented:
I know how to check if the check box is checked, just like you showed above however that  code isn't helpful because I need to be able to tell if the check box is enabled or disabled? I have several check boxes that are checked, but they are also disabled. So again I need to know how to check if they are enabled or disabled.
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
brgdotnetcontractor

Author

Commented:
Thank you so much, great help !!!!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions