Skip to main content
Participant
July 19, 2023
Question

PDF Tabbing action with multiple choice radio button group

  • July 19, 2023
  • 2 replies
  • 644 views

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!

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
July 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.

Participant
July 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.

Thom Parker
Community Expert
Community Expert
July 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 PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
July 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 PDFScriptingUse the Acrobat JavaScript Reference early and often