【发布时间】:2014-02-26 15:49:59
【问题描述】:
我想通过 javascript 对 html 表单上的 ckeckbox 中选择的值求和 请参阅以下示例:
<form>
<input type="checkbox" id="digit_1">
<input type="checkbox" id="digit_2">
<input type="checkbox" id="digit_3">
<input type="checkbox" id="digit_4">
<div id="result"></div>
<input type="submit">
</form>
所以我想在javascript中给复选框值如下图:
digit_1 = 10
digit_2 = 5
digit_3 = 1
digit_4 = 20
And for example when "digit_1" and "digit_3" selected , it show sum of it (11) in the result div 当“digit_3”已删除 = 11 - 1 = 10 在 div 中显示 10 个数字
【问题讨论】:
-
你能发布你目前的代码吗?
-
您没有将值放入 HTML 中是否有原因?
-
no .. 发送结果值无关紧要...我只想在结果 div 中显示数字的总和
标签: javascript html forms input