1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2 <HTML> 3 <HEAD> 4 <TITLE>New Document</TITLE> 5 <META NAME="Generator" CONTENT="EditPlus"> 6 <META NAME="Author" CONTENT=""> 7 <META NAME="Keywords" CONTENT=""> 8 <META NAME="Description" CONTENT=""> 9 </HEAD> 10 11 <BODY> 12 <TABLE width="100%" border="1" id="tb"> 13 <TR> 14 <TD><INPUT TYPE="text" NAME="a1" value="张三"></TD> 15 <TD><font color="red">男</font></TD> 16 <TD>21</TD> 17 </TR> 18 <TR> 19 <TD><INPUT TYPE="text" NAME="a2" value="李四"></TD> 20 <TD><font color="red">女</font></TD> 21 <TD>19</TD> 22 </TR> 23 </TABLE> 24 <SCRIPT LANGUAGE="JavaScript"> 25 <!-- 26 getValue(); 27 function getValue() { 28 alert("表格总行数=" + tb.rows.length); 29 for (i = 0; i < tb.rows.length; i++) { 30 Names = tb.rows[i].cells[0].getElementsByTagName("INPUT")[0].value; 31 gender = tb.rows[i].cells[1].innerHTML; 32 age = tb.rows[i].cells[2].innerText; 33 alert(Names); 34 alert(gender); 35 alert(age); 36 } 37 } 38 //--> 39 </SCRIPT> 40 </BODY> 41 </HTML>