troubleshooting Question

How to check if a check box is active using Java Script?

Avatar of brgdotnet
brgdotnetFlag for United States of America asked on
JavaScript
2 Comments1 Solution177 ViewsLast Modified:
I am able to check  all check boxes in my GridView control using Java script. When I press a button it calls my  java script "checkAll".
It works great however I need to change the code so that it first checks if a check box control is active before setting it to a value of true.
How can I do that? There is no "Active" or "Enabled" property, so I can't take that approach :  inputList[i].checked.enabled

So how can I check if a check box is enabled using Java Script



<script type = "text/javascript">
function checkAll(objRef)
{
    var GridView = objRef.parentNode.parentNode.parentNode;
    var inputList = GridView.getElementsByTagName("input");
    for (var i=0;i<inputList.length;i++)
    {
        //Get the Cell To find out ColumnIndex
        var row = inputList[i].parentNode.parentNode;
        if(inputList[i].type == "checkbox")
        {
                inputList[i].checked=true;
        }

    }

}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 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 2 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