Skip to main content
good4nothing
Participant
February 6, 2018
Answered

Check all checkbox code

  • February 6, 2018
  • 1 reply
  • 536 views

Hi all,

I'm a coding noob and can do basic stuff but I can not for the life of me figure out how to code a check box (checkall) to select yes on 20 or so radio buttons (radio1-20)for marking rather than having to select each one. But I still need to be able to change some individual radio buttons to no  and if unselected clear all radiobox if required. Can someone point me in the right direction. I assume I need to create an array and code on a mouse up for the check box. Just not sure how to proceed.

This topic has been closed for replies.
Correct answer Thom Parker

Use a button Mouse Up Script.  The easiest solution is to prefix all the radio button names with something like "Group1.".  The "dot" at the end is critical. This groups the fields so they can be handled as a group. Next, make sure all the Yes buttons have an export value of "Yes". Now put this code in the button script

this.getField("Group1").getArray().forEach(function(a){a.value = "Yes";});

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
February 6, 2018

Use a button Mouse Up Script.  The easiest solution is to prefix all the radio button names with something like "Group1.".  The "dot" at the end is critical. This groups the fields so they can be handled as a group. Next, make sure all the Yes buttons have an export value of "Yes". Now put this code in the button script

this.getField("Group1").getArray().forEach(function(a){a.value = "Yes";});

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
good4nothing
Participant
February 8, 2018

Thank you!