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

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

New Here ,
Apr 24, 2016 Apr 24, 2016

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript

Views

3.8K

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 , Apr 24, 2016 Apr 24, 2016

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

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

Votes

Translate

Translate
Community Expert ,
Apr 24, 2016 Apr 24, 2016

Copy link to clipboard

Copied

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

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

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
New Here ,
Apr 24, 2016 Apr 24, 2016

Copy link to clipboard

Copied

Perfect.  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
New Here ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

I've used this code to do the same thing with a fillable form in Adobe Acrobat Pro DC. However, when I'm viewing the form in Acrobat Reader, the checkbox does the opposite of what it should. When it is unchecked, it populates a number in another field, and when checked, that other field is 0.

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 ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

That should not be the case... Are you saying it's working well in Acrobat but not in Reader? Are you sure you're opening it in Reader and not in some other application, like inside a browser window?

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
New Here ,
Aug 21, 2021 Aug 21, 2021

Copy link to clipboard

Copied

I posted a similar question but found your answer and it worked.  Thank you very much.

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
Explorer ,
Jan 19, 2024 Jan 19, 2024

Copy link to clipboard

Copied

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.

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
Explorer ,
Jan 19, 2024 Jan 19, 2024

Copy link to clipboard

Copied

@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.

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 ,
Jan 19, 2024 Jan 19, 2024

Copy link to clipboard

Copied

LATEST

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

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