HighDots Forums  

Looping through HTML Table

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Looping through HTML Table in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
aroraamit81@gmail.com
 
Posts: n/a

Default Looping through HTML Table - 06-20-2007 , 09:23 AM






Hi,

How to loop through HTML Table in Javascript, I want to check if any
of check box in my HTML Table is checked or not.

Thnx in advance

Amit


Reply With Quote
  #2  
Old   
kaaposc
 
Posts: n/a

Default Re: Looping through HTML Table - 06-20-2007 , 01:15 PM






kaaposc wrote:
Quote:
aroraamit81 (AT) gmail (DOT) com wrote:
Hi,

How to loop through HTML Table in Javascript, I want to check if any
of check box in my HTML Table is checked or not.

depends on structure of your table.
in general way it should be something like:

// first we get all rows
var rows = new Array();
rows = document.getElementById("tableId").getElementsByTa gName("TR");

// next we can loop through this array and get all cells
for(var i = 0; i < rows.length; i++) {
var cells = new Array();
cells = rows[i].getElementsByTagName("TD");
}

so you can loop through cells for each row to check if there is <input
type="checkbox" /> and if it is checked.

ok, similar way to get all checkboxes is:

document.getElementById("tableId").getElementsByTa gName("INPUT");

then loop through all input to check 1)if it's type is checkbox and 2)if
it is checked.

--
-- kaaposc
"The Knowledge is Power"


Reply With Quote
  #3  
Old   
aroraamit81@gmail.com
 
Posts: n/a

Default Re: Looping through HTML Table - 06-21-2007 , 07:05 AM



Thnx Mate!

Regards

Amit


Reply With Quote
  #4  
Old   
intrader
 
Posts: n/a

Default Re: Looping through HTML Table - 09-09-2007 , 01:37 AM



aroraamit81 (AT) gmail (DOT) com wrote:
Quote:
Hi,

How to loop through HTML Table in Javascript, I want to check if any
of check box in my HTML Table is checked or not.

Thnx in advance

Amit

You have a feasible answer.
Consider naming your checkboxes with the same id. Then you can say

var checkboxesArray = document.getElementById("checkboxId")

and then loop through the array of checkboxes.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.