Copy link to clipboard
Copied
I am attempting to set the value of a radio button is a text box contains data. I get the error messahe "SyntaxError: invalid property id 1: at line 2.
Here is my code.
If({{#assign "involvedPersonsVar"}} {{listIndex externalOffenses "involvedPersons" 1 }} {{/assign}} {{listIndex "involvedPersonsVar" "lastName" 1 filterField="involvement.name" filterValue="VICTIM_IN_OFFENSE"}}().length > 0)
this.getField(“Wit1").value="Victim";
else
this.getField("Wit1").value="";
Any help would be appreciated.
Copy link to clipboard
Copied
Hello @Scott547,
Take a look here https://acrobatusers.com/forum/javascript/set-radio-button-based-value-another-field/ to see if it helps you.
Regards,
Mike
Copy link to clipboard
Copied
Mike,
Thank you for your quick response. I checked out the link and I get the same error code as before. I have a Radio button (Wit1) with 3 options, :Witness", "Passenger" and "Victim". I have tagged the name filed from another program to fill in the PDF so I know that if data is present it will be a victim name and the length will be greater than 0. Then I only want to check the "Victim" radion button. If there is no name, then I do not want to have any button checked. I did add the code to turn off the button at the beginning. Any ideas?
Copy link to clipboard
Copied
This is not valid Acrobat JS syntax. Far from it...
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Please explain what you're trying to achieve in simple text, not using (faulty) code examples.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Let's say that radio button's group name is "Group1" and that 'Victim' is 3rd button in a group, you need to access that button individual widget, widgets start from 0, so 3rd button have widget number of 2, so you would access that button by adding its widget number to the name of that group like this: "Group1.2"
As validate script of that text field, use this:
if(event.value != "")
this.getField("Group1.2").checkThisBox(0,true);
Copy link to clipboard
Copied
How is the data being imported into the file, exactly? The issue is that importing data doesn't usually trigger any calculation scripts, so you'll have to do so manually, or place the code as a doc-level script, and then re-open the file after importing the data for it to "kick in".
Copy link to clipboard
Copied
Use this as 'Validation' script of text field:
this.getField("Wit1").value = event.value == "" ? "Off" : "Victim";
Copy link to clipboard
Copied
Thank you for the input Nesa but the code does not work.
I'm still searching how to set one of 3 radio buttons in the same group based upon data in a test field.