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

If then statement with checkboxes

New Here ,
Jun 18, 2019 Jun 18, 2019

Copy link to clipboard

Copied

I am playing around with an inspection form and am trying to decide if radio buttons or check boxes are the better option. I am trying to program if then statements for checkboxes so that when a checkbox is selected, a point value is displayed in a specific text box. I learned how to accomplish this with radio buttons so I am hoping the philosophy is similar for checkboxes. Below is what I am trying to do. The code is accepted in the PDF form but nothing is being populated. Any help is much appreciated.

event.value = "";

if (N/ACheckBox.isSelected()){

event.value = 1;

} if (GreenCheckBox.isSelected()){

event.value = 1;

} if (AmberCheckBox.isSelected()){

event.value = .5;

} if (RedCheckBox.isSelected()){

event.value = 0;

}

I am hoping that the point value will disappear if the statements are false too.

TOPICS
Create PDFs

Views

1.2K

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 , Jun 18, 2019 Jun 18, 2019

- That's not how you access a field in Acrobat JS.

- There's no such method as "isSelected".

Change this (and all other similar lines):

if (N/ACheckBox.isSelected()){

To:

if (this.getField("N/ACheckBox").isBoxChecked(0)){

Votes

Translate

Translate
Community Expert ,
Jun 18, 2019 Jun 18, 2019

Copy link to clipboard

Copied

- That's not how you access a field in Acrobat JS.

- There's no such method as "isSelected".

Change this (and all other similar lines):

if (N/ACheckBox.isSelected()){

To:

if (this.getField("N/ACheckBox").isBoxChecked(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
New Here ,
Oct 15, 2019 Oct 15, 2019

Copy link to clipboard

Copied

I'm looking for an answer to a similar situation. I have an inspection form that has 3 radio buttons for each of 20 questions. The buttons are for Yes, No and N/A where Yes and N/A = 5 points and No has no value. At the end of the form is a tally of all of the Yes/N/A to total a given score. If I set up each of the radio buttons as you have done here, can I do a simple total field at the bottom for each of the Groups? I'm always afraid I'll do something circular that I have trouble backing out of.

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 ,
Oct 15, 2019 Oct 15, 2019

Copy link to clipboard

Copied

Never mind! I figured it out and it was a lot easier than I initially thought. I'm glad to be getting the hang of this very useful tool!

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 04, 2024 Apr 04, 2024

Copy link to clipboard

Copied

LATEST

 

 

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