Skip to main content
jsilva-econolite
Participant
June 19, 2018
Answered

How would I use one checkbox to automatically check other checkboxes in a form?

  • June 19, 2018
  • 1 reply
  • 1461 views

I have a PDF form with multiple configuration options that allow submitters to check what they need. But we have one checkbox that requires two others to be selected as well, but users forget sometimes since it is manual.  I'd like to improve the functionality of the form so that when the user selects that first checkbox, Acrobat automatically checks the other two related checkboxes for the user.  How would I go about doing that?

This topic has been closed for replies.
Correct answer jsilva-econolite

Assuming Button3 is the checkbox that this script runs on, it will check the checkboxes for Button1 and Button2.  AppAlerts can be used to communicate why the linkages occur.  This doesn't uncheck the values of Button1 and Button2 if Button3 is then unchecked.  If that is necessary, copy/paste the two lines into the ELSE section and change the 'Yes' to 'Off'.

if (this.getField("Button3").value != "Off") {

    this.getField("Button1").value = "Yes";

    this.getField("Button2").value = "Yes";

    //app.alert("Lorem Ipsum...")

}

else {

    //app.alert("Lorem Ipsum...")

}

1 reply

jsilva-econolite
jsilva-econoliteAuthorCorrect answer
Participant
June 28, 2018

Assuming Button3 is the checkbox that this script runs on, it will check the checkboxes for Button1 and Button2.  AppAlerts can be used to communicate why the linkages occur.  This doesn't uncheck the values of Button1 and Button2 if Button3 is then unchecked.  If that is necessary, copy/paste the two lines into the ELSE section and change the 'Yes' to 'Off'.

if (this.getField("Button3").value != "Off") {

    this.getField("Button1").value = "Yes";

    this.getField("Button2").value = "Yes";

    //app.alert("Lorem Ipsum...")

}

else {

    //app.alert("Lorem Ipsum...")

}

Participant
April 18, 2023

Can you explain in more detail?