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

If then statement with checkboxes

New Here ,
Jun 18, 2019 Jun 18, 2019

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
1.7K
Translate
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
1 ACCEPTED SOLUTION
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)){

View solution in original post

Translate
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 ,
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)){

Translate
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
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.
Translate
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
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!
Translate
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
LATEST

 

 

Translate
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