Highlighted

Can a checkbox selection control the value of a cell?

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

Topics

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

Views

44

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

Can a checkbox selection control the value of a cell?

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

Topics

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

Views

45

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
Most Valuable Participant ,
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;

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
Reply
Loading...
Community Beginner ,
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?

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
Reply
Loading...
Most Valuable Participant ,
Jul 23, 2020

Copy link to clipboard

Copied

Sure.

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
Reply
Loading...
Community Beginner ,
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!

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
Reply
Loading...
Most Valuable Participant ,
Jul 23, 2020

Copy link to clipboard

Copied

Yes. Change the first line to just:

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

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
Reply
Loading...
cmurph88 LATEST
Community Beginner ,
Jul 23, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Resources
One Stop Solution for Acrobat
Edit a PDF