• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Set the value of a radio button if a text field contains data.

New Here ,
Dec 26, 2022 Dec 26, 2022

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.

TOPICS
Edit and convert PDFs , How to

Views

981

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 26, 2022 Dec 26, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 26, 2022 Dec 26, 2022

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 26, 2022 Dec 26, 2022

Copy link to clipboard

Copied

This is not valid Acrobat JS syntax. Far from it...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 26, 2022 Dec 26, 2022

Copy link to clipboard

Copied

My current script follows. I would appreciate your input to make it correct
syntax.

this.getField("Wit1").value="Off";

// Cleared radio buttons

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="Off";}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2023 Jan 16, 2023

Copy link to clipboard

Copied

Please explain what you're trying to achieve in simple text, not using (faulty) code examples.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 16, 2023 Jan 16, 2023

Copy link to clipboard

Copied

I have a fillable PDF form that gets data from a database. Fields on the
form are for a passenger, witness or victim. There is a radio button that
identifies which type of individual is listed. The field is to populate if
there is a victim in the data. If so the name will be tagged from the
database. If not, the field will be blank. I would like to have the radio
button with Victim checked if there is data.

Please let me know if this is unclear or you need anything.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2023 Jan 16, 2023

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

LATEST

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".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 26, 2022 Dec 26, 2022

Copy link to clipboard

Copied

Use this as 'Validation' script of text field:

this.getField("Wit1").value = event.value == "" ? "Off" : "Victim";

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 16, 2023 Jan 16, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines