js动态添加行列后如何取得添中在input里的name值!在线等,急呀!

一潭清水 2009-08-06 08:16:15
请高手指教!我想实现获得新增部分AA和BB的值!然后代入公式进行计算!
这是代码//
<table width="400" border="0" cellspacing="0" cellpadding="0" id="tblGrid">
<tr>
<td align="center">AA</td><td>
<input type="text" name="tj_hight" id="hight" size="5" ></td><td>
CM  × BB</td><td>
<input type="text" name="tj_width" id="width" size="5" ></td><td>
CM  </td><td><a href="javascript:void(0)" onclick="addRow1()">[新增]</a> </td>

</tr>
</table>

<script language="javascript">

//add a new row to the table
function addRow1()
{
//add a row to the rows collection and get a reference to the newly added row
var newRow = document.all("tblGrid").insertRow();

//add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes

var oCell = newRow.insertCell();
oCell.innerHTML = " AA";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='hight' size=5>";

oCell = newRow.insertCell();
oCell.innerHTML = " CM  × BB";

oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='width' size=5> ";

oCell = newRow.insertCell();
oCell.innerHTML = "CM     ";

oCell = newRow.insertCell();
oCell.innerHTML = "<input type='button' value='Delete' onclick='removeRow1(this);'>";

}

//deletes the specified row from the table
function removeRow1(src)
{
/* src refers to the input button that was clicked.
to get a reference to the containing <tr> element,
get the parent of the parent (in this case case <tr>)
*/
var oRow = src.parentElement.parentElement;

//once the row reference is obtained, delete it passing in its rowIndex
document.all("tblGrid").deleteRow(oRow.rowIndex);
}

</script>
...全文
528 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
一潭清水 2009-08-06
  • 打赏
  • 举报
回复
问题已自行解决,谢谢2楼热心肠人!
一潭清水 2009-08-06
  • 打赏
  • 举报
回复
<table width="400" border="0" cellspacing="0" cellpadding="0" id="tblGrid">
<tr>
<td align="center">长</td><td>
<input type="text" name="hight" id="hight" size="5" ></td>
<td> CM  × 宽</td><td>
<input type="text" name="tj_width" id="tj_width" size="5" ></td>
<td> CM  </td>
<td><a href="javascript:void(0)" onclick="addRow1()">[新增]</a> </td>
</tr> </table>

<script language="javascript">
function addRow1()
{
var newRow = document.all("tblGrid").insertRow();
var oCell = newRow.insertCell();
oCell.innerHTML = " 长";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='tj_hight' size=5>";
oCell = newRow.insertCell();
oCell.innerHTML = " CM  × 宽";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='tj_width' size=5> ";
oCell = newRow.insertCell();
oCell.innerHTML = "CM     ";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='button' value='Delete' onclick='removeRow1(this);'>";
}
function removeRow1(src)
{
var oRow = src.parentElement.parentElement;
document.all("tblGrid").deleteRow(oRow.rowIndex);
}
</script>
norman3036383 2009-08-06
  • 打赏
  • 举报
回复
代码给出的具体点·一下这么多谁看啊

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧