asp 动态添加文本框

asp 动态添加文本框,第1张

,保存数据时可以用ajax来做。以下代码可参考

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">

<title>增加Table行</title>

</head>

<script>

function addRow(obj)

{

//添加一行

var newTr = testTbl.insertRow()

//添加两列

var newTd0 = newTr.insertCell()

var newTd1 = newTr.insertCell()

//设置列内容和属性

newTd0.innerHTML = '<input type=checkbox id="box4">'

newTd1.innerText= '新加行'

}

</script>

<body>

<table id="testTbl" border=1>

<tr id="tr1">

<td ><input type=checkbox id="box1"></td>

<td id="b">第一行</td>

</tr>

<tr id="tr2">

<td ><input type=checkbox id="box2"></td>

<td id="b">第二行</td>

</tr>

<tr id="tr3">

<td ><input type=checkbox id="box3"></td>

<td>第三行</td>

</tr>

</table>

<br />

<input type="button" id="add" onclick="addRow()" value="Add Row" />

</body>

</html>

这个有点小麻烦的。用循环来控制。

HTML 页面,用变量来控制行数,变量初始值是1。当变量=1的时候,只显示一行,再给定 tr 一个初始ID,display=none,当点击增加的时候,ID+1,变量+1,display=""

同样 ASP 代码也用循环来一一获得 HTML 页面上的值


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11930244.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-19
下一篇2023-05-19

发表评论

登录后才能评论

评论列表(0条)

    保存