计算复选框 [英] calculating check boxes
本文介绍了计算复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在联系表7中遇到问题,我想寻求帮助。我遇到的问题是,我有一组复选框,当客户单击该复选框时,我希望进行全部显示。
I am facing a problem in contact form 7, and I would like to have some help. The problem that I am having is that I have a set of Check boxes that I would like to have a total show when a client clicks on it.
我的复选框:(多项选择)可以选择一个以上的
MY Check box: (multiple select ) can pick more then one
[checkbox GRCGA class:multipal use_label_element "$10.00" "$20.00" "$25.00" "$50.00" "$75.00" "$100.00" "$200.00" "$400.00" "$500.00"]
Total Amount: <span id="total">$00</span>.00
Jvascript :
Jvascript:
$("input[type=checkbox]").change(function(){
updateTotal();
});
function updateTotal(){
var total = 0;
$("input[type=checkbox]:checked").each(function(){
total += parseFloat($(this).val());
});
$("#total").html(total);
}
当他们选择一个或多个以获取总金额时,这项工作将获得总金额他们想要的数量。
Will this work to get the total amount when they select one or more to get the amount that they want.
推荐答案
<script>
$(document).ready(function() {
$("input[type=checkbox]").on("change", function() {
var tot = 0;
$("input[type=checkbox]:checked").each(function() {
var val = this.value.substr(1).split(' ')[0];
tot += +(val);
});
$("#result").text("Total: $" + tot);
});
});
</script>
希望这对您有帮助
这篇关于计算复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文