how to access a checkbox control located in a <td> cell and or a <span> tag.

I am using Java Script, and am required to use strictly Java Script and no JQuery.

Basically I have a large size web page. When a button on the page is clicked, a java script method "goThroughROws()" is called.
Basically the method needs to itereate through every row, and wherever a check box control has been encountered, the
Java Script method needs to uncheck all of the check box controls on the page.

My function will iterate through each row, However I am at a loss in trying to figure out how to iterate through each data table
cell and then to access each check box control inside of the data cell. Some of the checkbox controls are also contained in span tags, so that seems to add complexity to
the problem.

So in a nut shell, my question is asking how I can access each check box control located in the data cells, even if the check box controls are contained in span tags?


<table>
 <tr Id="Row_1">
   <td>Totals</td>
 </tr>

 <tr Id="Row_1">
   <td>Totals</td>
 </tr>

 <tr Id="cbxRow_1"> 
   <td><span name="123"><input id="rpt_ctl03$txtAmount" id="rpt_ctl03_altSelectBox" type="checkbox" name = "rpt$ctl03$altSelectBox" checked="checked"   </span></td>
 </tr>



</table>

Open in new window

function goThroughRows()
{

   var table = document.getElementById("PayTable");
   var r = 0;
   while(row=table.rows[r])
   {

	for(var c=0; m = table.rows[r].cells.length; c < m; c++)
        {
		var xx = table.rows[r].cells[c].innerHTML;
                alert(xx)

        }



   }





}

Open in new window

LVL 2
brgdotnetcontractorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Part of your problem is you are working with invalid html and js code.
http://jsbin.com/ximez/1/edit
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
  <meta charset="utf-8">
  <title>Q_28475871</title>
  <script>
 function goThroughRows() {
     var inputs = document.getElementsByTagName('input');
     for (var i = 0; i < inputs.length; i += 1) {
         inputs[i].checked = false;
     }
 }  
    </script>
</head>
<body>
  <button onclick="goThroughRows()">Unselect</button>
<table>
 <tr Id="Row_1">
   <td>Totals</td>
 </tr>

 <tr Id="Row_2">
   <td>Totals</td>
 </tr>

 <tr Id="cbxRow_1"> 
   <td>
     <span name="123">
       <input id="rpt_ctl03$txtAmount" id="rpt_ctl03_altSelectBox" type="checkbox" name = "rpt$ctl03$altSelectBox" checked="checked">
     </span>
   </td>
 </tr>
  
   <tr Id="cbxRow_2"> 
   <td>
     <span name="123">
       <input id="rpt_ctl03$txtAmount2" id="rpt_ctl03_altSelectBox" type="checkbox" name = "rpt$ctl03$altSelectBox" checked="checked">
     </span>
   </td>
 </tr>
  
   <tr Id="cbxRow_3"> 
   <td>
     <span name="123">
       <input id="rpt_ctl03$txtAmount3" id="rpt_ctl03_altSelectBox" type="checkbox" name = "rpt$ctl03$altSelectBox" checked="checked">
     </span>
   </td>
 </tr>



</table>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brgdotnetcontractorAuthor Commented:
Thanks Scott, getElementsByTagName works great. I might need to ask a different question that is very similar.
0
brgdotnetcontractorAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.