JS动态添加表格行

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN=给表格内部动态添加行/titlestyletype=text/css.tableStyle{border-collapse:collapse;width:100%;}td{font-size:12px;height:25px;border:1pxsolid#CCD5E8;}.btn{font-size:12pt;color:#003399;border:1px#003399solid;color:#006699;border-bottom:#93bee21pxsolid;border-left:#93bee21pxsolid;border-right:#93bee21pxsolid;border-top:#93bee21pxsolid;background-color:#e8f4ff;cursor:pointer;font-style:normal;width:20px;height:22px;font-family:Verdana;font-family:Georgia;_font-family:Tahoma;padding:010px1px;padding:3px3px1px;_padding:04px1px;line-height:18px;line-height:14px;_line-height:16px;}/style/headbodytableclass=tableStyleid=OwnershipStructuretrtdwidth=15%rowspan=2id=StructureLeft1标的企业股权结构/tdtdwidth=15%rowspan=2id=StructureLeft2股东人数:人/tdtdwidth=30%前十名出资人的名称strong(做成动态,填几个显示几个)/strong/tdtdwidth=30%出资比例/td/trtrid=StructureRighttdinputid=Text1type=text//tdtdinputid=Text2type=text/inputid=btnAddRowclass=btnonclick=AddStructureRow()type=buttonvalue=+//td/trtrtd评估机构/tdtd/tdtd/tdtd/td/trtrtd评估机构/tdtd/tdtd/tdtd/td/tr/tablescriptlanguage=javascripttype=text/javascript//表单操作functionAddStructureRow(){varobj=document.getElementById(OwnershipStructure);vartr=obj.rows[StructureRight];//alert(tr.rowIndex);varcount=document.getElementById(StructureLeft1).getAttribute(rowspan);document.getElementById(StructureLeft1).setAttribute(rowSpan,parseInt(count)+1);document.getElementById(StructureLeft2).setAttribute(rowSpan,parseInt(count)+1);//插入行codeform=obj.insertRow(tr.rowIndex+1);vartrId=trStructure+tr.rowIndex;tr.setAttribute(id,trId);vartd0=tr.insertCell(0);td0.setAttribute(align,left);//td0.setAttribute(colSpan,4);td0.innerHTML=inputID='txtName'type='text'/;vartd1=tr.insertCell(1);td1.setAttribute(align,left);//td1.setAttribute(colSpan,3);td1.innerHTML=inputID='txtName'type='text'/inputid='btnDelRow'class='btn'type='button'value='-'onclick='DelStructureRow(+tr.rowIndex+)'/;}functionDelStructureRow(rowIndex){varobj=document.getElementById(OwnershipStructure);obj.deleteRow(rowIndex);varcount=document.getElementById(StructureLeft1).getAttribute(rowspan);document.getElementById(StructureLeft1).setAttribute(rowSpan,parseInt(count)-1);//rowSpan不要写成rowspan,因为在IE6与IE7下会有问题document.getElementById(StructureLeft2).setAttribute(rowSpan,parseInt(count)-1);}//End---股东出资人表单操作/script/body/html

1 / 6
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功