我只是试图得到一个价格显示,更新onchange事件。现在,这只是向我展示onchange id的两个值,我只希望有人点击一个复选框,然后将已显示的价格更新为新值。更新价格上显示更改
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<table>
<tr>
<td>
<input type="checkbox" id="extras" value="25.00" onChange="calc()">
</td>
<td>
<input type="checkbox" id="rush" value="35.00" onChange="calc()">
</td>
<td>
<input id="total" type="text" value="90.00" />
</td>
</tr>
</table>
</body>
<script type='text/javascript'>
function calc() {
var extras = document.getElementById('extras').value;
var rush = document.getElementById('rush').value;
var result = document.getElementById("total");
result.value = extras + rush;
}
</script>
</html>
有这个问题,这么多的重复。使用jquery并检查此链接:http://stackoverflow.com/questions/4813219/jquery-checkbox-value –
不是真的 - 这是关于做警报。 – MrTechie
http://stackoverflow.com/questions/21442833/javascript-add-checkbox-checked-values – fasouto