Skip to main content
bb28222058
Participating Frequently
Apr 24, 2016 9:08 AM UTC
Answered

When a check box is checked, populate a text field with a value

I'm sure this is simple; however I am very new to acrobat and javascript.

Here is what I want to do:

I have a CheckBox field and a Text field. If the checkbox is "checked" I want to populate the text field with a specific numeric value.  If it is left "unchecked" there would be no value or 0 value.  Any help is appreciated.

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Apr 24, 2016 9:10 AM UTC

Enter this code as the custom calculation script of your text field:

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

8 replies

Known Participant
Jan 19, 2024 6:23 PM UTC

When I put in this script, it automatically puts my text field as '1234'. I need the text field to be editable by the user. For example, if check box 1 is checked, text field 1 needs a required population data of the users choice, i/e 1500, 1600, and so on.

Translate
Known Participant
Jan 19, 2024 6:26 PM UTC

@try67 When I put in this script, it automatically puts my text field as '1234'. I need the text field to be editable by the user. For example, if check box 1 is checked, text field 1 needs a required population data of the users choice, i/e 1500, 1600, and so on.

Translate
try67
Community Expert
Community Expert
Jan 19, 2024 10:28 PM UTC

So you want the check-box to only clear the text field, when No is selected?

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Apr 24, 2016 9:10 AM UTC

Enter this code as the custom calculation script of your text field:

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

Translate
bb28222058
Participating Frequently
Apr 24, 2016 3:27 PM UTC

Perfect.  Thank you.

Translate