Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Read All Cells from Dynamic Rows

Status
Not open for further replies.

hangon72

Programmer
Apr 22, 2005
2
US
Hi,

I have create a Table/TR and added a button which will populate dynamic rows.

Now I need a java script function which reads all the cells in each row and all the rows using Dom structure

for ex:

<table id="row" name="row>
<tr>
<td><input type="text" name="sun"</td>
<td><input type="text" name="mon"</td>
<td><input type="text" name="tue"</td>
<td><input type="text" name="wed"</td>
<td><input type="text" name="thu"</td>
<td><input type="text" name="fri"</td>
<td><input type="text" name="sat"</td>
</table>

There is a button I provided on the page when user clicks on that it creates a new row with all the elements above.

Now I need a java script function which reads all the cells in each row and all the rows by using Dom structure.

Please
 
Do you want us to write this JavaScript function for you?

Or have you started writing the function, but it's not working correctly?

<marc>
 
try this.

Code:
var table = document.getElementById("row");

for (var i = 0; i < table.rows.length; i++)
     for (var j = 0; j < table.rows[i].length; j++)
          /*do what ever you want with the cells
            access the cells by:
            table.rows[i].cells[j]
          */
 
On your way to implement way to read the value of the textbox control which happens to be in the cell [i,j] (0-based), this is a detail you might not get it rightaway:
[tt]
table.rows.cells[j].childNodes[0].value[/tt]

whereas if the cell store a simple string, you can do this.
[tt]
table.rows.cells[j].innerHTML[/tt]

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top