11 Replies Latest reply on Apr 28, 2014 12:35 PM by try67

# Need help with calculating based on checkbox result

I am trying to create a membership application in which the new member would check a checkbox next to the type of investment category they are applying for (see chart below).  For this example, I will use Business & Higher Education.

Once checked, the javascript would perform a calculation and add a total on the far right.  So, essentially, I'm trying to say:  If BHECheck (checkbox) is checked, add BHEBase (base rate of \$340) + BHED (dollar amount of \$6 per FTE) * NumberFTE (FTE total from first line on chart) which would be totaled in a field called BHETotal.  The calculation I've used is (BHEBase)+(BHED*NumberFTE).  If the box is not checked, I would like the total to be \$0.  I have the checkbox export value set as 1.  I am new to javascripting and really have very, very little knowledge of it, so please keep that in mind when responding.  Thank you!

• ###### 1. Re: Need help with calculating based on checkbox result

You can do it using JS, but you don't really need to... Use the Simple

Field Notation option, and multiply by the check-box's value at the end.

When it's checked it will multiply by 1 and you'll get the result you

calculated. When it's not checked the "Off" value will be converted to

zero, and the result will be zero automatically.

• ###### 2. Re: Need help with calculating based on checkbox result

I tried it using the following simplified notation and it's not working:  (BHEBase)+(BHED*NumberFTE)*(BHECheck)

• ###### 3. Re: Need help with calculating based on checkbox result

In what way is it nor working?

You may need to set the calculation order within the formula so the expected value is multiplied by zero or 1. Right now you are only multiplying the BHED times the NumberFTE by the check box value and then adding the BHEBase.

From your description I would try:

(BHEBase + (BHED * NumberFTE)) * BHECheck

• ###### 4. Re: Need help with calculating based on checkbox result

I made sure all of the checkbox export values are 1, but I'm still having problems with the calculation order.  This is what I currently have and it's not working:

((BHEBase)+(BHED*NumberFTE))*(BHECheck)

• ###### 5. Re: Need help with calculating based on checkbox result

Not working in what way, exactly? Does it produce the wrong result? Does it

do anything? Are there error messages in the JS console (Ctrl+J)?

• ###### 6. Re: Need help with calculating based on checkbox result

It doesn't do anything.  My result is still \$340 whether or not I check the box.

• ###### 7. Re: Need help with calculating based on checkbox result

Can you share the file in question (either via Dropbox, Acrobat.com, or

privately by email)?

• ###### 8. Re: Need help with calculating based on checkbox result

I just want to make sure I have the script in the correct field.  Right now, I have the checkbox export set as 1 and don't have any JS.  I am using the JS in the total field.

• ###### 9. Re: Need help with calculating based on checkbox result

As the Simple Field Notation code under the Calculate tab? If so, then yes, that's correct.

• ###### 10. Re: Need help with calculating based on checkbox result

Yes, I can via e-mail.  What e-mail should I send it to?

• ###### 11. Re: Need help with calculating based on checkbox result

See PM.