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

Can a checkbox selection control the value of a cell?

Community Beginner ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

I need a checkbox to fill the value of a cell when selected. Basically, if the checkbox is not selected, the cell value will be zero. If the checkbox is selected, the cell value will be the sum of three other cells which will be filled out on the PDF. Is there a custom calculation script that I can enter which will cause this to happen? I have searched other posts in forums and have not found one which will successfully do this. If needed, I can change the checkbox to be a radio button.

 

Let me know if I need to provide further details.

 

Thank you.

TOPICS
Create PDFs , Edit and convert PDFs , How to , PDF forms

Views

711

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 , Jul 21, 2020 Jul 21, 2020

Yes, this is easily done, but not with a radio-button (which can't be un-checked manually). Stick with a check-box and use this code as the custom calculation script of the text field:

 

var sum = Number(this.getField("A").valueAsString) + Number(this.getField("B").valueAsString) + Number(this.getField("C").valueAsString);

event.value = (this.getField("CheckBox1").valueAsString=="Off") ? 0 : sum;

Votes

Translate

Translate
Community Expert ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

Yes, this is easily done, but not with a radio-button (which can't be un-checked manually). Stick with a check-box and use this code as the custom calculation script of the text field:

 

var sum = Number(this.getField("A").valueAsString) + Number(this.getField("B").valueAsString) + Number(this.getField("C").valueAsString);

event.value = (this.getField("CheckBox1").valueAsString=="Off") ? 0 : sum;

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 ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

Worked perfectly, thank you so much! Could I use a variation on this script if I wanted only one cell's value to populate the value of another cell when a checkbox is checked?

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 ,
Jul 23, 2020 Jul 23, 2020

Copy link to clipboard

Copied

Sure.

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 ,
Jul 23, 2020 Jul 23, 2020

Copy link to clipboard

Copied

I have this code entered, but can't get it to work with a single cell:

 

var sum = Number(this.getField("MEAL REIMBURSEMENT TOTAL").valueAsString) + Number(this.getField("cell").valueAsString) + Number(this.getField("cell").valueAsString);

event.value = (this.getField("OVERNIGHT STAY NO").valueAsString=="On") ? 0 : sum;

 

I only need the value of the MEAL REIMBURSEMENT TOTAL cell to populalte in the cell this code is in when the checkbox is checked. Did I make an error?

 

Thank you!

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 ,
Jul 23, 2020 Jul 23, 2020

Copy link to clipboard

Copied

Yes. Change the first line to just:

var sum = Number(this.getField("MEAL REIMBURSEMENT TOTAL").valueAsString);

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 ,
Jul 23, 2020 Jul 23, 2020

Copy link to clipboard

Copied

LATEST

Thank you for all of your help! I truly appreciate it!

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