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

Adobe Javascript Radio Buttons Coordinates

New Here ,
May 31, 2021 May 31, 2021

Copy link to clipboard

Copied

Hi there.  I'm trying to rename a radio button using JS by creating a new radiobutton field.  There are 3 options layed out:

[ ]  Option 1

[ ]  Option 2

[ ]  Option 3

 

I'm trying to get the coords for each option using f.rect; but it returns the same coords regardless of which option I have checked.  Is there a way to do this?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.1K

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

correct answers 1 Correct answer

Community Expert , May 31, 2021 May 31, 2021

When fields have the same name, they are essentially the same field. In a PDF, a field is really a virtual thing. It's a name with an associated value. What the user sees on the screen is called a Widget. So your radio button group is 1 field with 3 widgets. By default, this.getField("FieldName") returns the 1st widget. To get the coordinates of the other widgets the widget ID is appended to the FieldName. 

 

So this.getField("FieldName.0") gets the first widget and  this.getField("FieldName.1")

...

Votes

Translate

Translate
Community Expert ,
May 31, 2021 May 31, 2021

Copy link to clipboard

Copied

When fields have the same name, they are essentially the same field. In a PDF, a field is really a virtual thing. It's a name with an associated value. What the user sees on the screen is called a Widget. So your radio button group is 1 field with 3 widgets. By default, this.getField("FieldName") returns the 1st widget. To get the coordinates of the other widgets the widget ID is appended to the FieldName. 

 

So this.getField("FieldName.0") gets the first widget and  this.getField("FieldName.1") gets the second widget, etc. 

 

 

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

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 ,
May 31, 2021 May 31, 2021

Copy link to clipboard

Copied

That worked!  Would it have killed them to put that in the reference, LOL.

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 ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

The information about widgets is available in the Acrobat Javascript Reference.

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 ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

And there's even an example of this exact issue:

 

try67_0-1622560154505.png

 

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
Engaged ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

Is there a way to find out the widget number of a rb group in the console or elsewhere?

I didn't find anything in the 2021 documentation on p. 386-387 and p. 424. It only states that the the widget number is determined by creation order, regardless of tab order. I don't recall the order the fields were created. I also know that I appended rb group as well as added widgets after the fact.

The field navigation tab only shows export values. Is it assumed that the widget order and field navigation order is the same?

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 ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

What do you mean by "the widget number of a rb group"? Do you mean the number of widgets?

If so, you can examine the length of the page array or the exportValues array. And yes, their order will match each other, as well as the widget index number within the group.

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
Engaged ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

I mean the widget number/widget index number. The zero-based number after a period of each widget.

 

I've attached what I see in the field navigation tab. It only shows the export values.

 

How would I go about this in the console? I wasn't able to find anything in the SDK regarding exportValues except for setting up new radio buttons. I don't know what you mean by length of page array.

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 ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

The first item in that list is index 0, the second is index 1, etc.

If you read the exportValues property of the field it should print it out in the right order.

Like this:

this.getField("card1").exportValues;

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
Engaged ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

LATEST

Thanks, I thought I tried that before I posted, but I must have written it singular or something (i.e. exportValue). 

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