日期:2014-05-16  浏览次数:20419 次

javascript 动态表格
function build_row(){    
     var table = document.getElementById("Table1");
     var rowTitle = table.insertRow();    
     var cell1 = rowTitle.insertCell();
     cell1.innerHTML = "&nbsp;<input name='childnam'  style='width:120px' type='text' onblur='checkSy();checkJg()'  maxlength='10' onKeyDown='if(event.keyCode==13)event.keyCode=9;' /><input name='child_id'  type='hidden'  maxlength='10' onKeyDown='if(event.keyCode==13)event.keyCode=9;'  value='' />";    
     var cell2 = rowTitle.insertCell();
     cell2.innerHTML = "<select name='childsex' style='width:50px' onKeyDown='onKD(0)' onchange='sumChild()'><%=v07.prog.optStr2(DBC,"select num,txt from fp_const where tag='syssex' and num>0 order by num",T[5])%></select>";
     var cell3 = rowTitle.insertCell();
     cell3.innerHTML = "<input name='childdat1'  type='text' onblur='cgdat();sumChild()'  maxlength='10' style='width:110px' onKeyDown='if(event.keyCode==13)event.keyCode=9;' />";
     var cell4 = rowTitle.insertCell();
     cell4.innerHTML = "<input name='childdat2'   type='text' onblur='cgdat();sumChild();changen3()'  maxlength='10' style='width:130px' onKeyDown='if(event.keyCode==13)event.keyCode=9;'  />";
     var cell5 = rowTitle.insertCell();
     cell5.innerHTML = "<select name='childremark'  style='width:90px'  onblur='checkSy()' onKeyDown='onKD(0)' ><option value='0'>亲生</option><option value='2'>继子女</option><option value='1'>收养</option><option value='3'>寄养</option></select>";
     var cell5 = rowTitle.insertCell();
     cell5.innerHTML = "<span style='cursor:hand;width:190px;text-align: center' onclick='delRow(this);checkSy();'>&nbsp;X&nbsp;删除&nbsp;</span>";
}    

function delRow(obj){    
    var tr = obj.parentElement.parentElement;    
    var tb = tr.parentElement.parentElement; 
    tb.deleteRow(tr.rowIndex);    
    
 }

?

?

? 留着下次就可以 直接用了。。O(∩_∩)O哈哈~