Calculate totals in Web Form Builder?...

User 49135 Photo


Registered User
14 posts

Hello,
I have a simple web form that I need to calculate totals for three or four fields before it gets sent to PayPal. Scott on the support site with CoffeeCup suggested I ask over here. He said we've got some wonderful help with any coding issues over here.

Thank you in advance for any tips, suggestions, etc that you can provide.

Loretta

Work Hard | Play Hard
User 187934 Photo


Senior Advisor
20,238 posts

Hi Elgie,
I have several examples in the form builder thread. Can you share a link to your form to make it easier to help you?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 49135 Photo


Registered User
14 posts

Hi Eric,
Thank so much for the response. Here is the form I've been working on
http://skippydance.coffeecup.com/forms/ … ship_dues/

I really appreciate your time.
L.
Work Hard | Play Hard
User 187934 Photo


Senior Advisor
20,238 posts

Give this a try.Version 1
Paste the code into a HTML element on your form.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
// version 1
jQ( document ).ready(function() {

jQ('input[name="number5"]').prop('readonly', true);
jQ('input[name="number9"]').prop('readonly', true);
jQ('#item12_0_checkbox').val(100);
jQ('#item12_1_checkbox').val(50);
jQ('#item12_2_checkbox').val(50);
jQ('input[name="cont_scholarship"]').addClass( "sum" );
jQ('#item12_0_checkbox').addClass( "sumdues" );
jQ('input[name="checkbox12[]"]').on('click', function() {
if (jQ(this).is(":checked")){
jQ(this).addClass( "sumdues" );
}else{
jQ(this).removeClass( "sumdues" );
}

calc_dues();
});
// Calculates on scholarship change
jQ('input[name="cont_scholarship"]').on('change', function() {

calc_dues();
});

// This is the calculate function
function calc_dues() {

var sum_member = 0;

jQ('.sumdues').each(function(){

if(jQ.isNumeric(this.value)){

sum_member += parseFloat(this.value);

jQ('input[name="number5"]').val(sum_member);

var CSFund = jQ('input[name="cont_scholarship"]').val();
if(jQ.isNumeric(CSFund) && CSFund >0){
var grandTotal = parseFloat(CSFund) + sum_member;

jQ('input[name="number9"]').val(grandTotal);
} else {jQ('input[name="number9"]').val(sum_member);
}
}
});
}
//This runs the calculate function on load to fill in already checked values
calc_dues();
});
</script>

You can see it working here.
http://ericrohloff.com/coffeecup/ccforu … der/elgie/
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 49135 Photo


Registered User
14 posts

THANK YOU THANK YOU THANK YOU!!!!!!

Eric YOU ROCK!!!!!

Have an incredible weekend!

Thank you so much!
Work Hard | Play Hard
User 2484360 Photo


Registered User
3,293 posts

Elgie wrote:
Eric YOU ROCK!!!!!


He really does... :)
User 187934 Photo


Senior Advisor
20,238 posts

Thanks. Hope it does what you need.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 49135 Photo


Registered User
14 posts

Hello, hello again. I'm kind of hoping Eric sees this, cuz he helped me so much before.

I browsed through the code you sent me on the previous form, and I can't see how you made the totals work:/ I just pasted it in, and it worked.

I have another form, that needs totals, and can't see how to implement it. If anyone could help, I'd really, really appreciate it!

Here is the form:
http://skippydance.coffeecup.com/forms/ … ime_Sheet/

If the employee works on a certain day, then the rest of the fields appear. One of those fields in Total Number of Hours. The client would like any of those daily totals to auto add at the very end.

I took some screen shots with explanation in this PDF[ (sorry I couldn't get the PDF to load here), so here it is:
https://www.dropbox.com/s/rkwrf6m4zngzt … g.pdf?dl=0

Thank you in advance for any help, tips, suggestions!
L.
Work Hard | Play Hard
User 187934 Photo


Senior Advisor
20,238 posts

Could you go through the form and give the totals a common name attribute. Like hourstotalwk1mon, hourstotalwk1tues, hourstotalwk2mon, hourstotalwk2tues and so on?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 49135 Photo


Registered User
14 posts

Yep, on it right now! I'll let you know when I get that done. :)
Work Hard | Play Hard

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.