Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


JavaScript for checkboxes and costs

Community Beginner ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Is there a way to write a javascript for adding the cost of items IF their checkbox is checked?  I have an inventory sheet.  I need to check off what items someone will be getting.  But as I check each box, I need each item's cost to add up in a separate field.

TOPICS
How to, JavaScript, PDF forms

Views

52

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Sep 10, 2021 Sep 10, 2021
You actually don't need to use any scripts for this. Just set the price as the Export Value of each check-box and then select them directly in the Sum function under the Calculate tab of the total field.

Likes

Translate

Translate
Adobe Community Professional ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Yes , it is possible.

 

Have you tried writing your own script yet?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

No, but only because I don't really know how.  Is there like a YouTube video or something?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

Hi dmk59,

 

You could put the following script in the Custom Calculation Script of the line total that refers to the relevant line checkbox, and then have a "total" at the bottom, and that sums each line that has been 'checked' - obviously the export value of the checkbox might need changing from the example below, as will the pricing and field naming;

 

event.value = this.getField("Checkbox1").value == 1 ? "100.00" : "";

 

 

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

LATEST

Thank you for your help!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

You actually don't need to use any scripts for this. Just set the price as the Export Value of each check-box and then select them directly in the Sum function under the Calculate tab of the total field.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

YOU. ARE. AN. ANGEL!!!  Thanks!  I keep having to make these forms and I'm probably not the best condidate for it.  This answer is exactly what I needed.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines