java_菜鸟,js表格动态增加行
程序员文章站
2022-03-01 21:24:39
...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>增加Table行</title>
</head>
<script>
function addRows(loopNum){
if(loopNum == 0 || loopNum == '' || loopNum == undefined ){
return false;
}
try{
var i =0;
while(i < loopNum){
var rows = tbl_looopaddrow.insertRow(); //给该表格增加一格行
var clmn1= rows.insertCell(); //该行增加几列
var clmn2= rows.insertCell();
var clmn3= rows.insertCell();
var clmn4= rows.insertCell();
var clmn5= rows.insertCell();
var clmn6= rows.insertCell();
var clmn7= rows.insertCell(); //该行增加几列
var clmn8= rows.insertCell();
var clmn9= rows.insertCell();
var clmn10= rows.insertCell();
var clmn11= rows.insertCell();
var clmn12= rows.insertCell();
clmn1.innerHTML="<input name=txt_seqno1 type=text id =txt_seqno/>";
clmn2.innerHTML="<input name=txt_seqno2 type=text id =txt_seqno/>";
clmn3.innerHTML="<input name=txt_seqno3 type=text id =txt_seqno/>";
clmn4.innerHTML="<input name=txt_seqno4 type=text id =txt_seqno/>";
clmn5.innerHTML="<input name=txt_seqno5 type=text id =txt_seqno/>";
clmn6.innerHTML="<input name=txt_seqno6 type=text id =txt_seqno/>";
clmn7.innerHTML="<input name=txt_seqno7 type=text id =txt_seqno/>";
clmn8.innerHTML="<input name=txt_seqno8 type=text id =txt_seqno/>";
clmn9.innerHTML="<input name=txt_seqno9 type=text id =txt_seqno/>";
clmn10.innerHTML="<input name=txt_seqno10 type=text id =txt_seqno/>";
clmn11.innerHTML="<input name=txt_seqno11 type=text id =txt_seqno/>";
clmn12.innerHTML="<input name=txt_seqno12 type=text id =txt_seqno/>";
i++;
}
}catch(e){}
}
</script>
<body>
<input type = 'text' name ='txt_payAcctCount' onblur = 'addRows(this.value)';/>
<table border =1 id='tbl_looopaddrow'>
<tr>
<td> <label name='lbl_bt2'>标题1<label/> </td>
<td> <label name='lbl_bt3'>标题2<label/> </td>
<td> <label name='lbl_bt4'>标题3<label/>
<td> <label name='lbl_bt5'>标题4<label/>
<td> <label name='lbl_bt'>标题5<label/>
<td> <label name='lbl_bt1'>标题6<label/>
<td> <label name='lbl_bt2'>标题7<label/> </td>
<td> <label name='lbl_bt3'>标题8<label/> </td>
<td> <label name='lbl_bt4'>标题9<label/>
<td> <label name='lbl_bt5'>标题10<label/>
<td> <label name='lbl_bt'>标题11<label/>
<td> <label name='lbl_bt1'>标题12<label/>
</tr>
</table>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>增加Table行</title>
</head>
<script>
function addRows(loopNum){
if(loopNum == 0 || loopNum == '' || loopNum == undefined ){
return false;
}
try{
var i =0;
while(i < loopNum){
var rows = tbl_looopaddrow.insertRow(); //给该表格增加一格行
var clmn1= rows.insertCell(); //该行增加几列
var clmn2= rows.insertCell();
var clmn3= rows.insertCell();
var clmn4= rows.insertCell();
var clmn5= rows.insertCell();
var clmn6= rows.insertCell();
var clmn7= rows.insertCell(); //该行增加几列
var clmn8= rows.insertCell();
var clmn9= rows.insertCell();
var clmn10= rows.insertCell();
var clmn11= rows.insertCell();
var clmn12= rows.insertCell();
clmn1.innerHTML="<input name=txt_seqno1 type=text id =txt_seqno/>";
clmn2.innerHTML="<input name=txt_seqno2 type=text id =txt_seqno/>";
clmn3.innerHTML="<input name=txt_seqno3 type=text id =txt_seqno/>";
clmn4.innerHTML="<input name=txt_seqno4 type=text id =txt_seqno/>";
clmn5.innerHTML="<input name=txt_seqno5 type=text id =txt_seqno/>";
clmn6.innerHTML="<input name=txt_seqno6 type=text id =txt_seqno/>";
clmn7.innerHTML="<input name=txt_seqno7 type=text id =txt_seqno/>";
clmn8.innerHTML="<input name=txt_seqno8 type=text id =txt_seqno/>";
clmn9.innerHTML="<input name=txt_seqno9 type=text id =txt_seqno/>";
clmn10.innerHTML="<input name=txt_seqno10 type=text id =txt_seqno/>";
clmn11.innerHTML="<input name=txt_seqno11 type=text id =txt_seqno/>";
clmn12.innerHTML="<input name=txt_seqno12 type=text id =txt_seqno/>";
i++;
}
}catch(e){}
}
</script>
<body>
<input type = 'text' name ='txt_payAcctCount' onblur = 'addRows(this.value)';/>
<table border =1 id='tbl_looopaddrow'>
<tr>
<td> <label name='lbl_bt2'>标题1<label/> </td>
<td> <label name='lbl_bt3'>标题2<label/> </td>
<td> <label name='lbl_bt4'>标题3<label/>
<td> <label name='lbl_bt5'>标题4<label/>
<td> <label name='lbl_bt'>标题5<label/>
<td> <label name='lbl_bt1'>标题6<label/>
<td> <label name='lbl_bt2'>标题7<label/> </td>
<td> <label name='lbl_bt3'>标题8<label/> </td>
<td> <label name='lbl_bt4'>标题9<label/>
<td> <label name='lbl_bt5'>标题10<label/>
<td> <label name='lbl_bt'>标题11<label/>
<td> <label name='lbl_bt1'>标题12<label/>
</tr>
</table>
</body>
</html>