<table id="table1" width="60%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>分值</td>
</tr>
<logic:present name="demoList">
<logic:iterate id="demo" name="demoList">
<tr>
<td>${demo.point}</td>
</tr>
</logic:iterate>
</logic:present>
</table>
<script language="javascript">
<!--点击"修改分值"按钮-->
function updatepoint(){
<!--遍历所有分值td,将td的innerHTML改为文本框,将之前的分值做为该文本框的值-->
for(var i=1; i<table1.rows.length; i++){
var point = table1.rows[i].cells[0];
point.innerHTML="<input type='text' name='testA' size='8' value='"+point.innerText+"'>";
}
<!--改变"修改分值"按钮为"保存分值"-->
document.getElementById("butt").innerHTML="<input name="update" type="button" onclick="totalpoint()" value="保存分值"/>";
}
<!--计算分值合是否为100-->
function totalpoint(tt){
var total=0;
for(var i=0; i<document.all.testA.length; i++){
total+=Number(document.all.testA[i].value);
}
if(total != 100){
alert("你输入的权重合为:"+total+"\n权重合必须为100\n请重新输入!");
return false;
}
<!--如果权重合为100就提交表单-->
document.forms[0].submit();
}
</script>