js动态添加行列后如何取得添中在input里的name值!在线等,急呀!
请高手指教!我想实现获得新增部分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>
这是代码//
<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>
...全文
相关推荐
javascript实现的动态添加表单元素input,button等(appendChild)
给大家介绍了javascript实现的动态添加表单元素input,button等(appendChild)的实例代码,非常不错,具有一定的参考借鉴价值,需要的朋友参考下吧
JavaScript动态添加并验证Input输入框项目
在现代Web开发中,事件监听是创建交互式用户界面的关键。事件监听是一种机制,允许我们捕捉并响应用户的操作,如点击、按键、鼠标移动或页面加载等事件。通过事件监听,开发者可以执行代码来响应这些事件,从而实现如按钮点击打开菜单、表单提交前验证输入等动态交互。事件监听不仅限于简单的用户交互,它还扩展到浏览器事件,例如窗口加载完成、滚动、资源加载状态改变等。在JavaScript中,方法提供了一种添加事件监听器到元素的标准方式,让开发者可以指定在特定事件发生时应该调用的函数。
js点击连续添加input输入框并且判断值
代码主要实现点击添加多个input输入框,并对每个输入框里的数据进行判断
JS获得多个同name 的input输入框的值的实现方法
主要介绍了基于JS代码实现input密码输入框输入密码变黑点密文以及JS获得多个同name 的input输入框的值的实现方法,代码简单易懂,非常不错,具有参考借鉴价值,需要的朋友参考下
vuejs 动态添加input框的实例讲解
今天小编就为大家分享一篇vuejs 动态添加input框的实例讲解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧


