Copy link to clipboard
Copied
I'm trying to use radio buttons to select a "sample type". Upon selection, I want the form to default certain tests to that particular sample type.
For example, selecting PARTS would default the Salmonella, Campylobacter, and EB testing radio buttons on..
I'm fairly new to Acrobat and JS so any help or advise is greatly appreciated. I'm learning on the fly. Thank you in advance!
Copy link to clipboard
Copied
So the "Analysis Needed" elements are checkboxes? If they are radio buttons, then only one can be selected. I think you need to change this.
So you need to create a relationship between the "Sample Type" selection and the Analysis selections. Do this with an object, where the entries are the export values from the Sample Type radio buttons, and the values are an array of selections for analysis
var oSampleTypes = {"Parts":["Salmonella", "Campylobacter", "EB"], "Reuse Water":[...], etc};
Use this on a selection to set the Analysis check boxes. These names of these checkboxes must exactly match the names listed in the object defined above. An easy way to do this is to add a text field and put the script into the calculation for that text field. This text field is on used to run the script. It has no other purpose and should be hidden.
Here are some article that will help:
This one is for dropdowns, but the technique used is exactly what you need here:
https://acrobatusers.com/tutorials/change_another_field/
https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm