在页面表格中动态增加一行单元格

<script>
function hideList(obj_id,img)
{
var obj=document.getElementById(obj_id);
if(obj.style.display=="none")
{
obj.style.display="";
if(img!=null)
img.src=img.src.replace("hide_b.gif","expand_b.gif");
}else
{
obj.style.display="none";
if(img!=null)
img.src=img.src.replace("expand_b.gif","hide_b.gif");
}
}
function addRow(){
var table=document.getElementById("content_table_left");
var tr=table.getElementsByTagName("tr");
var rowN=tr.length-1;
tableRow=table.insertRow();
tableRow.style.background="white";

tableCell1=tableRow.insertCell(0);
tableCell2=tableRow.insertCell(0);
tableCell3=tableRow.insertCell(0);

tableCell1.align="center";

tableCell1.innerHTML="<input type='hidden' name='supplyList["+rowN+"].enabled'/><input type='hidden' name='supplyList["+rowN+"].changeFlag' id='supplyList["+rowN+"].changeFlag'/><input type='hidden' name='supplyList["+rowN+"].isAdd' id='supplyList["+rowN+"].isAdd'/><input type='checkbox' class='noBorder' checked='checked' οnchange='changeCheckBox(this);changeAddRow(this)'/>";
tableCell2.innerHTML="<input type='text' name='supplyList["+rowN+"].description' οnchange='changeAddRow(this);' />";
tableCell3.innerHTML="<input type='text' name='supplyList["+rowN+"].supplyCenterCode' οnchange='changeAddRow(this);' />";
}
</script>
<html>
<title>test add row</title>
<body>
<div class="c_title_layout"><span><img
src="<app:ContextPath/>/images/expand_b.gif"
οnclick="hideList('searchCondition',this);"
width="16" eight="16" align="absbottom">  Search Conditions</span></div>
<DIV class="gap10px"></div>
<div id="searchCondition">

<table width="100%" border="0" align="center" cellpadding="1"
cellspacing="1" class="input_data_table">
<tr class="bg_white">


<td class="input_data_table_td">Supply Center.  <span
style="color:#FF0000;">*</span></td>
<td><input id="inputSearchSupplyCenterCode" name="inputSearchSupplyCenterCode" type="text" value=""/>
</td>
</tr>
</table>
<DIV class="gap10px"></div>
<div style="text-align: center">
<input type="hidden" id="backSearchCondition"/>
<input name="search"
type="button" class="button" value="Search" οnclick="validateNull();" id="searchId"/>
   <input name="clear" type="button" class="button"
value="Clear" οnclick="clearInfo();" />

</div>
</div>
<div id="resultList">
<input class="button" type="button"
οnclick="addRow();" value="  Add  "
id="addButton"/>
<input type="button" class="button" value=" Save " id="saveSubmit"
οnclick="saveSubmit1();"/>      
</div>
<table width="100%" border="0" cellpadding="1" cellspacing="1"
id="content_table_left" class="list_data_table">
<tr align="left">
<td class="input_data_table_td" align="left">
<strong>Field1 test1</strong>
</td>
<td class="input_data_table_td" align="left">
<strong>Field2 test2</strong>
</td>
<td class="input_data_table_td" align="center">
<strong>Enabled</strong>
</td>
</tr>
</table>
</body>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值