页面代码如下~我想动态的生成table,已实现,但是如何取得值?以下代码只能取出一行的值,不知道那里写错了。希望指点下!!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<button onClick="add()">add</button>
<button onClick="test()">test</button>
<table id="t1" border="1">
</table>
<script language="JavaScript">
function add()
{
var row = t1.insertRow();
for(i=0; i<3; i++){
row.insertCell().innerHTML = '<input name="test'+t1.rows.length+'">';
}
}
function test()
{
for(i=1;i<=t1.rows.length;i++) {
for(j=1;j<t1.cells.length;j++){
alert(i);
alert(j);
alert(t1.rows[i].cells[j].innerHTML);
}
}
}
</SCRIPT>
</body>
</html>
[此贴子已经被作者于2007-7-16 21:37:20编辑过]