• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

548

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

Community Expert , 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.

Votes

Translate

Translate
Community Expert ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Yes , it is possible.

 

Have you tried writing your own script yet?

Votes

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?

Votes

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
Engaged ,
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" : "";

 

 

 

 

Votes

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!

Votes

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 Expert ,
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.

Votes

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.

Votes

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