<ptml> <pead> <meta http-equiv= "content-language" content= "ZH-CN" > <meta http-equiv= "content-ty PE "content=" text/html; charset=gb2312 "> <title>222222 </title> </pead> <body> <table border=" 1 "width=" 45% "he ight= "id=" "table1" > <tr> <td> <input type= "checkbox" Name= "C1" value= "on" > </td> <TD&G t; Cloud Community </td> <td>www.jb51.net</td> </tr> <tr> <td> <input type= "checkbox" Name= "C2" value= "on" > </td> <td> Baidu </td> <td>www.baidu.com</td> </tr> <tr> ;td> <input type= "checkbox" Name= "C3" value= "on" > </td> <td> Server Software </td> <td> s.jb51.net</td> </tr> </table> <input type= "button" onclick= "Readarray ()" value= "Get Tabular Value" > < Script>//Use array to get table value function Getrowtext () {var arr = new Array (); var count = 0; for (var i=0;i <table1.rows.length;i++) {var row = Table1.rows[i]; Get checkbox var Objcheck = row.cells[0].getelementsbytagname ("INPUT") [0]; If the checkbox is selected. Add to two-dimensional array if (Objcheck!=null && objcheck.checked) {//arr[i]= row.innertext; Arr[count] = new Array (); for (var x=0;x <row.cells.length;x++) {//Excluding the cell contents of the Radio box if (x==0) continue; Arr[count][x-1] = Row.cells[x].innertext; } count++; } return arr; //Read table value function Readarray () {var arr = Getrowtext (); for (var i=0;i <arr.length;i++) {//Get the value of each row for (Var x= 0;x <arr[i].length;x++) {document.write (arr[i][x)); }} </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Definitions and usage
The Rows collection returns an array of all rows (TableRow objects) in the table, that is, a htmlcollection.
The collection includes all the lines defined in <thead>, <tfoot>, and <tbody>.
Grammar
Tableobject.rows[] Instance
The following example uses the Rows collection to display the contents of the first row:
<ptml> <pead> <script type= "Text/javascript" > F Unction Showrow () {Alert (document.getElementById (' myTable '). rows[0].innerhtml)} </script> </pead> < body> <table id= "myTable" border= "1" > <tr> <td>row1 cell1</td> <td>row1-cell2</td > </tr> <tr> <td>row2 cell1</td> <td>row2 cell2</td> </tr> </TABLE&G T <input type= "button" onclick= "Showrow ()" value= "show InnerHTML" > </body> </ptml>
[ctrl+a All selected note: If you need to introduce external JS need to refresh to perform ]