动态创建删除table表
function createTable(){
var i=document.getElementById("sumnumber").value;
i=parseInt(i)+1;
document.getElementById("sumnumber").value=i;
var div = document.getElementById("model2");
var table = document.createElement("table");//创建table
table.width="94%";
table.border="0";
table.cellpadding="0";
table.cellspacing="0";
table.id="submenu6688";
var row = table.insertRow();//创建一行
var cell = row.insertCell();//创建一个单元
// cell.style.backgroundColor = "#999999";
cell.colSpan="4";
cell.innerHTML=" ";
var row = table.insertRow();
cell = row.insertCell();//创建一个单元
cell.height="24";
cell.align="right";
cell.innerHTML="<span class='STYLE19'>* </span>您是被保险人的:";
//div.appendChild(table);
cell=row.insertCell();
cell.width="250";
cell.align="left";
cell.innerHTML="<select id='sltrelation"+i+"' height='20px' name='sltrelation"+i+"'><option selected>请选择</option> <option>配偶</option><option>子女</option><option>父母</option><option>其它</option></select>"
cell=row.insertCell();
cell.width="100";
cell.innerHTML=" ";
cell=row.insertCell();
cell.width="100";
cell.innerHTML=" ";
// 增加一行
row=table.insertRow();
cell=row.insertCell();
cell.height="24";
cell.align="right";
cell.innerHTML="<span class='STYLE19'>* </span>被保险人姓名:";
cell=row.insertCell();
cell.align="left";
cell.innerHTML="<input id='txtsubto"+i+"' type='text' name='txtsubto"+i+"' />";
cell = row.insertCell();//创建一个单元
cell.height="24";
cell.align="right";
cell.innerHTML="<span class='STYLE19'>* </span>英文名/拼音:";
cell=row.insertCell();
cell.align="left";
cell.innerHTML="<input type='text' id='txtEnName"+i+"' name='txtEnName"+i+"' width='100px'/>";
row=table.insertRow();
cell=row.insertCell();
cell.height="24";
cell.align="right";
cell.innerHTML="<span class='STYLE19'>* </span>证件类型:";
cell=row.insertCell();
cell.align="left";
cell.innerHTML="<select id='sltsfz' name='sltsfz"+i+"'><option selected='true'>请选择</option><option>身份证</option><option>护照</option></select>";
cell=row.insertCell();
cell.align="right";
cell.innerHTML="<span class='STYLE19'>* </span>证件号码:";
cell=row.insertCell();
cell.align="left";
cell.innerHTML="<input id='txtzjnumber"+i+"' width='160px' type='text' name='txtzjnumber"+i+"' />";
row=table.insertRow();
cell=row.insertCell();
cell.height="24";
cell.align="right";
cell.innerHTML="<span class='STYLE19'>* </span>出生日期:";
cell=row.insertCell();
cell.align="left";
cell.innerHTML="<script language='javascript' type='text/javascript' src='DatePicker/WdatePicker.js'><"+"/script><input id='txtborndate"+i+"' width='100px' type='text' name='txtborndate"+i+"' onClick='WdatePicker()'/>";
cell=row.insertCell();
cell.align="right";
cell.innerHTML="<span class='STYLE19'>* </span> 性别:";
cell=row.insertCell();
cell.align="left";
cell.innerHTML="<select id='sltsex"+i+"' height='20px' name='sltsex"+i+"' ><option selected>请选择</option><option>男</option><option>女</option></select>"
row=table.insertRow();
cell=row.insertCell();
cell.height="24px";
cell.align="right";
cell.innerHTML="联系电话:";
cell=row.insertCell();
cell.colSpan="3";
cell.innerHTML="<input id='txtphone"+i+"' width='160px' type='text' name='txtphone"+i+"' /><label><span class='STYLE21'>非必填项,建议填写以便享受短信服务</span></label>";
cell.align="left";
cell=row.insertCell();
row=table.insertRow();
cell=row.insertCell();
cell.innerHTML=" ";
cell=row.insertCell();
cell.innerHTML=" ";
cell=row.insertCell();
cell.innerHTML=" ";
cell=row.insertCell();
cell.innerHTML=" ";
div.appendChild(table);
var oldmoney=document.getElementById("cdstree").innerHTML;
var metamoney=document.getElementById("metamoney").value;
var currentmoney=parseInt(oldmoney)+parseInt(metamoney);
document.getElementById("cdstree").innerHTML=currentmoney;
document.getElementById("fenshu").innerHTML=i;
}
function del()
{
var div = document.getElementById("model2");
var i=document.getElementById("sumnumber").value;
i=parseInt(i);
if(i>1)
{
div.removeChild(div.lastChild);
i=i-1;
document.getElementById("sumnumber").value=i;
var oldmoney=document.getElementById("cdstree").innerHTML;
var metamoney=document.getElementById("metamoney").value;
var currentmoney=parseInt(oldmoney)-parseInt(metamoney);
document.getElementById("cdstree").innerHTML=currentmoney;
document.getElementById("fenshu").innerHTML=i;
}
}