Skip to main content
turbo2514
Participant
June 18, 2019
Answered

If then statement with checkboxes

  • June 18, 2019
  • 2 replies
  • 1945 views

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.

This topic has been closed for replies.
Correct answer try67

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

2 replies

Participant
April 4, 2024

 

 

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 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)){

Participant
October 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.
Participant
October 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!