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

PDF Tabbing action with multiple choice radio button group

Community Beginner ,
Jul 19, 2023 Jul 19, 2023

I am using this code for my 'yes' or 'no' radio button groups in a PDF form;

if (event.target.value == "Yes") {this.getField("FIELD1").setFocus();}
else if (event.target.value == "No") {this.getField("FIELD2").setFocus();}
}

But, I have a group of radio buttons with 6 choices and all the JavaScript I've tried either ignores the second get field when tabbing or auto-selects when I arrow down to the next option. I know there must be a simple way but nothing is working. Thanks in advance!

TOPICS
PDF , PDF forms
503
Translate
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 ,
Jul 19, 2023 Jul 19, 2023

What are the 6 choices and what code are you using?

 

If the code above is used in a "MouseUp" action on both the "Yes/No" radio buttons, then it is redundant.  The user  is clicking on either the Yes or No button, and the MouseUp is specific to the button, so you only need this code:

// Use this code in the Mouse up for the Yes button

this.getField("FIELD1").setFocus(); 

 

// Use this code in the Mouse up for the No button

this.getField("FIELD2").setFocus(); 

 

Do the same for your other fields. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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 ,
Jul 20, 2023 Jul 20, 2023

To set the focus to an individual widget in the group you need to access it directly. For example:

this.getField("FIELD1.1").setFocus();

This will set the focus to the second widget in the "FIELD1" group.

If you don't specify a widget number, the first widget (index number 0) will get the focus by default.

Translate
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 Beginner ,
Jul 20, 2023 Jul 20, 2023

Thank you, it worked for 1 and 2 but I have 6 radio buttons, is there a way to group them so that if Choice1 is selected, it tabs to PatientReturnToDate textbox, and if any other Choice is selected, it tabs to the PrognosisComments textbox.Screen Shot 2023-07-20 at 8.46.28 AM.pngexpand image

Translate
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 ,
Jul 20, 2023 Jul 20, 2023

The answer is yes, and I already provided a working solution. 

Go back and read the answer. 

If you want more detail, then post the form. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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 Beginner ,
Jul 20, 2023 Jul 20, 2023

That code didn't work

Translate
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 ,
Jul 20, 2023 Jul 20, 2023
LATEST

I can assure you it does work.

Did you change the field name to match the name on your form? 

Did you look in the console window to see if there were any reported errors? 

 

Post the form and we'll take a look at it. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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