日期:2014-05-19  浏览次数:20449 次

求解动态生成表格问题.
怎么样才能在一个页面中,每点击一次按钮就能表格就能多生成一行?

------解决方案--------------------
用javascript的dom进行添加
可以很简单,可以很复杂,不知道你的具体情况~~
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>

<BODY>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function AddLine()
{
var obj = document.getElementById( "tb1 ");
obj.innerHTML = obj.innerHTML + " <tr> <td> 添加的...... </td> </tr> ";
}
//-->
</SCRIPT>
<table id= "tb1 " width= "100% " bgcolor= "#FF0000 ">
<tr>
<td> Test.... </td>
</tr>
</table>
<input type= "button " id= "btn1 " value= "添加 " onclick= "AddLine(); " />
</BODY>
</HTML>

------解决方案--------------------
<html>
<head>
<title> New Page 2 </title>
<script language=javascript>
function add(){
var tr=document.all.t.insertRow();
tr.insertCell().innerHTML= "tr> <td> 添加的...... </td> </tr> ";
}
</script>
</head>

<body>
<table id= "tb1 " width= "100% " bgcolor= "#ff0000 ">
<tr>
<td> Test.... </td>
</tr>
</table>
<form>
<input type=button onclick= 'add() ' value=add_a_row>
</form>
</body>
</html>

------解决方案--------------------
var tr=document.all.t.insertRow();改位var tr=document.all.tb1.insertRow();
手误了

------解决方案--------------------
你要的那那个更好实现,你看看msdn

------解决方案--------------------
用服务器Table控件+Ajax