how to subtract, two values from two sets of radio buttons.?
My radio buttons:
<p>Baby Plan<br />
[radio BPSUBPT id:BPSUBPT "Baby Plan $300.00 3 Sessions" "Baby Plan $500.00 4 Sessions"] </p>
<p>Did you have a Newborn session With ADP? <br />
[radio BUSPQ1 id:BUSPQ1 "Yes $150.00 off" "No $000.00"]
my java code that I have to calculate the total: ( but it adding it up I would like it to subtract to get the total.
<script>
$(document).ready(function() {
var inputs = $('input[name="BPSUBPT"], input[name="BUSPQ1"]');
$(inputs).click(function() {
var total = 0;
$(inputs).filter(':checked').each(function() {
var value = ($(this).val()).match(/\$([0-9]*)/)[1];
total = total + parseInt(value);
})
$('#total').html('$' + total);
how do I get it to subtract to get a total.
then subtract...
<script>
$(document).ready(function() {
var inputs = $('input[name="BPSUBPT"], input[name="BUSPQ1"]');
$(inputs).click(function() {
var total = 0;
$(inputs).filter(':checked').each(function() {
var value = ($(this).val()).match(/\$([0-9]*)/)[1];
total = total - parseInt(value);
})
$('#total').html('$' + total);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.