自己做的一个添加删除,计算比例的问题,求帮忙处理BUG
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var i = 1;
function tianjia(){
var j=i+1;
document.getElementById("d").innerHTML+='<div id="tr_'+i+'"><table width="100%" border="0" cellpadding="0" cellspacing="1"><tr height="30px"><td align="right" class="td_dingge" bgcolor="#FFFFFF">所占比例:</td><td align="left" class="td_dingge" bgcolor="#FFFFFF"><input name="rate'+i+'" id="rate'+i+'" type="text" size="4" onkeyup="jsbili()" />% *</td></tr><tr height="30px"><td colspan="4" height="40" bgcolor="#FFFFFF" align="center"><!--<label>第'+j+'个奖项</label>--><input type="button" value="删除" onclick="del('+i+')"/></td></tr></table></div>';
document.getElementById("panduanshu").value=i;
i = i + 1;
}
function del(o){
document.getElementById("d").removeChild(document.getElementById("tr_"+o));
i=i-1;
}
function jsbili(){
var bili=document.getElementById("panduanshu").value;
var zbili=parseInt(0);
for(var j=0;j<=bili;j++)
{
var ratebili=document.getElementById("rate"+j).value;
var xbili=0;
if(ratebili=="")
{
xbili=0;
}
else if(isNaN(ratebili))
{
xbili=0;
alert("比例只能是数字");
document.getElementById("rate"+j).value="";
}
else
{
var xbili=parseInt(ratebili);
}
zbili+=xbili;
}
if(zbili>100)
{
document.getElementById("sbili").value="超出总比例!!";
return false;
}
else
{
var sbili=parseInt(100-zbili);
document.getElementById("sbili").value=sbili;
return true;
}
}
</script>
</head>
<body>
<input type="hidden" name="panduanshu" id="panduanshu" value="0">
<table width="100%" border="0" align="center" cellpadding="0"
cellspacing="0" class="dh_boder">
<tr>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#eaeceb"><div id="d">
<table width="100%" border="0" cellpadding="0" cellspacing="1">
<tr height="30px">
<td align="right" class="td_dingge" bgcolor="#FFFFFF"> 所占比例:</td>
<td align="left" class="td_dingge" bgcolor="#FFFFFF"><in