Calculate totals in Web Form Builder?


Registered User
29 posts

Thank you. Will test it soon and let you know.
>don<


Senior Advisor
17,491 posts
Online Now

Don wrote:
Thank you. Will test it soon and let you know.

Make sure you make the changes I listed.;)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
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 personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com


Registered User
29 posts

Eric,

It works great! Thank you!

Been doing some testing about your idea to use Radio Buttons instead of check boxes. Realize I didn't try very hard the first time you asked me and now believe that may be the way to go.

Will be back after more testing.

BTW, where can I find good tutorial for learning jQ language?
>don<


Senior Advisor
17,491 posts
Online Now

Here's one site.
https://learn.jquery.com/
I'm glad it worked for ya. The only other thing I was going to tell you was about the decimal places in the costs and total. I have my code setup to place two decimal places at the end of the amount. If you don't want the decimal places I can tell you how to turn that feature off otherwise make sure you setup those inputs to be two decimal places within the form builder.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
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 personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com


Senior Advisor
17,491 posts
Online Now

Give this a try with your current checkbox setup. It only allows one box to be checked for each group so there could only be 3 checked per person registering. I updated mine to include this feature so you can see how it works.
http://ericrohloff.com/coffeecup/don/fill-cost.html
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
//ver 3.0
var jQ = $.noConflict(true);
jQ(document).ready(function(){
jQ("input[name^='COST']").attr('readonly', true);
jQ("input[name='TOTAL']").attr('readonly', true);
// Create expired date
var expiredDate = new Date("02/06/2018");
// Get today's date
var todaysDate = new Date();

jQ("input[name^='FUNC']").change(function() {
jQ("input[name^='COST']").val("");
var COST1 = 0;
var COST2 = 0;
var COST3 = 0;
var COST4 = 0;
var COST5 = 0;

jQ.each(jQ("input[name^='FUNC']:checked"), function(){
var name = jQ("input[name^='FUNC']:checked").attr("name");
var numbers = this.name.match(/\d+/);

// call setHours to take the time out of the comparison
if(expiredDate.setHours(0,0,0,0) > todaysDate.setHours(0,0,0,0)) {

//*** set the cost if before expired date for first FUNC ***//
if(jQ(this).is(':checked') && jQ(this).val() == "ADLT MBR REG"){
eval('var ADLT_MBR_REG' + numbers + '=40');}else {eval('var ADLT_MBR_REG' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "COL MBR REG"){
eval('var COL_MBR_REG' + numbers + '=15');}else {eval('var COL_MBR_REG' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "JOI MBR REG"){
eval('var JOI_MBR_REG' + numbers + '=10');}else { eval('var JOI_MBR_REG' + numbers + '=0');}

//*** set the cost if before expired date for second FUNC ***//
if(jQ(this).is(':checked') && jQ(this).val() == "ADLT LCH"){
eval('var ADLT_LCH' + numbers + '=25');}else {eval('var ADLT_LCH' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "CHLD LCH"){
eval('var CHLD_LCH' + numbers + '=10');}else {eval('var CHLD_LCH' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "ADLT DIN"){
eval('var ADLT_DIN' + numbers + '=40');}else { eval('var ADLT_DIN' + numbers + '=0');}

//*** set the cost if before expired date for third FUNC ***//
if(jQ(this).is(':checked') && jQ(this).val() == "CHLD DIN"){
eval('var CHLD_DIN' + numbers + '=10');}else {eval('var CHLD_DIN' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "ADLT BFT"){
eval('var ADLT_BFT' + numbers + '=15');}else {eval('var ADLT_BFT' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "FST TMR"){
eval('var FST_TMR' + numbers + '=0');}else { eval('var FST_TMR' + numbers + '=0');}

}else{
//*** set the cost if after expired date for first FUNC ***//
if(jQ(this).is(':checked') && jQ(this).val() == "ADLT MBR REG"){
eval('var ADLT_MBR_REG' + numbers + '=45');}else {eval('var ADLT_MBR_REG' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "COL MBR REG"){
eval('var COL_MBR_REG' + numbers + '=20');}else {eval('var COL_MBR_REG' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "JOI MBR REG"){
eval('var JOI_MBR_REG' + numbers + '=15');}else { eval('var JOI_MBR_REG' + numbers + '=0');}

//*** set the cost if after expired date for second FUNC ***//
if(jQ(this).is(':checked') && jQ(this).val() == "ADLT LCH"){
eval('var ADLT_LCH' + numbers + '=30');}else {eval('var ADLT_LCH' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "CHLD LCH"){
eval('var CHLD_LCH' + numbers + '=10');}else {eval('var CHLD_LCH' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "ADLT DIN"){
eval('var ADLT_DIN' + numbers + '=35');}else { eval('var ADLT_DIN' + numbers + '=0');}

//*** set the cost if after expired date for third FUNC ***//
if(jQ(this).is(':checked') && jQ(this).val() == "CHLD DIN"){
eval('var CHLD_DIN' + numbers + '=10');}else {eval('var CHLD_DIN' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "ADLT BFT"){
eval('var ADLT_BFT' + numbers + '=20');}else {eval('var ADLT_BFT' + numbers + '=0');}

if(jQ(this).is(':checked') && jQ(this).val() == "FST TMR"){
eval('var FST_TMR' + numbers + '=0');}else { eval('var FST_TMR' + numbers + '=0');}
}

eval('var ADLT_MBR_REG_NUM = ADLT_MBR_REG' + numbers);
eval('var COL_MBR_REG_NUM = COL_MBR_REG' + numbers);
eval('var JOI_MBR_REG_NUM = JOI_MBR_REG' + numbers);
eval('var ADLT_LCH_NUM = ADLT_LCH' + numbers);
eval('var CHLD_LCH_NUM = CHLD_LCH' + numbers);
eval('var ADLT_DIN_NUM = ADLT_DIN' + numbers);
eval('var CHLD_DIN_NUM = CHLD_DIN' + numbers);
eval('var ADLT_BFT_NUM = ADLT_BFT' + numbers);
eval('var FST_TMR_NUM = FST_TMR' + numbers);


//*** This passes the variable into the next cost input and sums the variables ***//
if(numbers == 11 || numbers == 12 ||numbers == 13){

COST1 += Number(ADLT_MBR_REG_NUM)+Number(COL_MBR_REG_NUM)+Number(JOI_MBR_REG_NUM)+Number(ADLT_LCH_NUM)+Number(CHLD_LCH_NUM)+Number(ADLT_DIN_NUM)+Number(CHLD_DIN_NUM)+Number(ADLT_BFT_NUM)+Number(FST_TMR_NUM) ;

jQ("input[name='COST1']").val(parseFloat(COST1).toFixed(2));

}
if(numbers == 21 || numbers == 22 ||numbers == 23){

COST2 += Number(ADLT_MBR_REG_NUM)+Number(COL_MBR_REG_NUM)+Number(JOI_MBR_REG_NUM)+Number(ADLT_LCH_NUM)+Number(CHLD_LCH_NUM)+Number(ADLT_DIN_NUM)+Number(CHLD_DIN_NUM)+Number(ADLT_BFT_NUM)+Number(FST_TMR_NUM) ;

jQ("input[name='COST2']").val(parseFloat(COST2).toFixed(2));
}
if(numbers == 31 || numbers == 32 ||numbers == 33){

COST3 += Number(ADLT_MBR_REG_NUM)+Number(COL_MBR_REG_NUM)+Number(JOI_MBR_REG_NUM)+Number(ADLT_LCH_NUM)+Number(CHLD_LCH_NUM)+Number(ADLT_DIN_NUM)+Number(CHLD_DIN_NUM)+Number(ADLT_BFT_NUM)+Number(FST_TMR_NUM) ;

jQ("input[name='COST3']").val(parseFloat(COST3).toFixed(2));
}
if(numbers == 41 || numbers == 42 ||numbers == 43){

COST4 += Number(ADLT_MBR_REG_NUM)+Number(COL_MBR_REG_NUM)+Number(JOI_MBR_REG_NUM)+Number(ADLT_LCH_NUM)+Number(CHLD_LCH_NUM)+Number(ADLT_DIN_NUM)+Number(CHLD_DIN_NUM)+Number(ADLT_BFT_NUM)+Number(FST_TMR_NUM) ;

jQ("input[name='COST4']").val(parseFloat(COST4).toFixed(2));
}
if(numbers == 51 || numbers == 52 ||numbers == 53){

COST5 += Number(ADLT_MBR_REG_NUM)+Number(COL_MBR_REG_NUM)+Number(JOI_MBR_REG_NUM)+Number(ADLT_LCH_NUM)+Number(CHLD_LCH_NUM)+Number(ADLT_DIN_NUM)+Number(CHLD_DIN_NUM)+Number(ADLT_BFT_NUM)+Number(FST_TMR_NUM) ;

jQ("input[name='COST5']").val(parseFloat(COST5).toFixed(2));
}


});
calctotal();



function calctotal(){
var total = 0;
jQ("input[name^='COST']").each(function(){
var value = jQ(this).val();
if(value >0 && jQ.isNumeric(value)){
total+=parseFloat(jQ(this).val(),10);
}
});
jQ("input[name=TOTAL]").val(total.toFixed(2))
}

});
jQ("input:checkbox").change(function() {
if (this.checked) {
var checkname = jQ(this).attr("name");
jQ("input:checkbox[name='" + checkname + "']").removeAttr("checked");
this.checked = true;
}
});

});
</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
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 personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com


Registered User
29 posts


Thanks Eric,

I'm still using script you posted 4:45 PM, 11/11/17.

And, am simplifying the form using radio buttns ILO check boxes. Where ever possible I'm retaining same var names.

And, plan to take a stab at modifying the jG script.

How do I change this from check box to radio button.

//*** set the cost if before expired date for first FUNC ***//
if(jQ(this).is(':checked') && jQ(this).val() == "ADLT MBR REG"){
eval('var ADLT_MBR_REG' + numbers + '=40');}else {eval('var ADLT_MBR_REG' + numbers + '=0');}




>don<


Senior Advisor
17,491 posts
Online Now

Please explain what the user should be allowed to check before making modifications as you may be making more work out of this for both you and me.;)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
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 personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com


Registered User
29 posts

Eric,

I'll let you know changes when and if I need you to create the script for me. Give me a chance to fix it for myself. I think if you answer this question I'll be able to do it. Suspect I need to replace ":checked" with something.

How do I change this code from check box to radio button.

//*** set the cost if before expired date for first FUNC ***//
if(jQ(this).is(':checked') && jQ(this).val() == "ADLT MBR REG"){
eval('var ADLT_MBR_REG' + numbers + '=40');}else {eval('var ADLT_MBR_REG' + numbers + '=0');}
>don<


Registered User
29 posts

Failed to mention I'm doing my practicing with a new form.

RegForm.fb is intact and unchanged.
>don<


Senior Advisor
17,491 posts
Online Now

Don wrote:
Eric,

I'll let you know changes when and if I need you to create the script for me. Give me a chance to fix it for myself. I think if you answer this question I'll be able to do it. Suspect I need to replace ":checked" with something.

How do I change this code from check box to radio button.

//*** set the cost if before expired date for first FUNC ***//
if(jQ(this).is(':checked') && jQ(this).val() == "ADLT MBR REG"){
eval('var ADLT_MBR_REG' + numbers + '=40');}else {eval('var ADLT_MBR_REG' + numbers + '=0');}

It stays the same whether it's a checkbox or a radio button.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
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 personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com

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.