Skip to main content
bbpatch
Participating Frequently
January 22, 2018
Answered

Setting a Checkbox Export Value to a Value in another field.

  • January 22, 2018
  • 1 reply
  • 20818 views

Hello! How might I go about setting a Checkbox's exportValue to the value placed in another text field? The value in that text field will change periodically, so I would want that exportValue to change with it.

I have a D&D character sheet that auto-sums the skill checks. The checkbox will represent if a character is proficient with said skill. So if that box is checked, I want it to add the proficiency bonus.

Thank you!

This topic has been closed for replies.
Correct answer Thom Parker

The export value is set with the "exportValues" property, but this property must be an array, cause it's used for radio buttons as well.

Put this script in the Validate script for the field that will set the check box export:

this.getField("Checkbox").exportValues = [event.value];

Don't forget to change "Checkbox" to the name of your fields

1 reply

Thom Parker
Thom ParkerCorrect answer
Community Expert
January 22, 2018

The export value is set with the "exportValues" property, but this property must be an array, cause it's used for radio buttons as well.

Put this script in the Validate script for the field that will set the check box export:

this.getField("Checkbox").exportValues = [event.value];

Don't forget to change "Checkbox" to the name of your fields

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
New Participant
February 12, 2020

I am having a similar issue...

 

 From: https://dnd5echaractersheet.com/wp-content/uploads/2017/10/DnD_5E_CharacterSheet-Form-Fillable.pdf 

 

 

I am trying to get the Acrobatics (Acrobatics) box to total up the Dexterity Modifier Box (DexMod) and if the check box (Check_Acrobatics) in front of it is checked, add the Proficiency Bonus (ProfBonus) for a total that can change depending on the number in ProfBonus. In this example it's a 3, so should total a 5.

The Acrobatics Box is currently using a Calculate formula that is auto generated:

 

I tried using this solution of this.getField("ProfBonus").exportValues = [event.value]; in the Check_Acrobatics check field export value:

 

But it doesn't autocalculate from a 2 to a 5 when it is checked...

 

This is exactly what the OP was asking to do, even if perhaps he didn't explain it clearly for a Non-D&D player to understand...  That when a box is checked, it change the skill (Acrobatics) based on the Stat Modifier (DexMod) plus the Proficiency Bonus (ProfBonus) if the check box (Check_Acrobatics) is checked, and just the Stat Modifier (DexMod) if the check box (Check_Acrobatics) isn't checked.  I hope I explained our problem adequately.

 

If I put a 3 in the Check Box's Field Export instead of the this.getField("Checkbox").exportValues = [event.value]; then it does give me a 2 or a 5 depending on how the box is checked or unchecked...

New Participant
February 4, 2021

Hi Thom,

I am the friend Default is referencing.

We are asking for MrBlonde87's solution, because I am experiencing the same concatenating issue with your last post. Your last post concatenates the values. So either the Number() which should work isn't or something is missing from the actual calculation to add event.value and the number. 

I've tried switching Number() to parseInt() and parseFloat() to no avial.


So, I figured something out but I have no idea why this works. And why Thom's last post doesnt.

 

event.value = Number(this.getField("DEXMod").value);
if(this.getField("CheckAcrobatics").value !="Off")
event.value = Number(this.getField("DEXMod").value) + Number(this.getField("ProfBonus").value);