<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
function compute(){
var arr=document.getElementsByName('check');
var sum=0;
for(i in arr){
if(arr[i].checked){
var money=parseFloat(document.getElementsByName('money')[i].value);
sum=sum+money;
}
}
document.forms[0].al.value=sum;
}
</script>
</head>
<body>
<form>
<table border="1">
<tr>
<td>金额</td><td>是否求和</td>
</tr>
<tr>
<td><input type="text" name="money"></td><td><input type="checkbox" name="check" /> </td>
</tr>
<tr>
<td><input type="text" name="money"></td><td><input type="checkbox" name="check" /> </td>
</tr>
<tr>
<td><input type="text" name="money"></td><td><input type="checkbox" name="check" /> </td>
</tr>
<tr>
<td><input type="text" name="al"></td><td><input type="button" name="sum" value="求和" onclick="compute()"/> </td>
</tr>
</table>
</form>
</body>
</html>
选择求和
最新推荐文章于 2022-03-23 16:43:42 发布