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.
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;
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;
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?
Copy link to clipboard
Copied
Sure.
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!
Copy link to clipboard
Copied
Yes. Change the first line to just:
var sum = Number(this.getField("MEAL REIMBURSEMENT TOTAL").valueAsString);
Copy link to clipboard
Copied
Thank you for all of your help! I truly appreciate it!