Radio Button Groups

Community Beginner ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

Its that same old problem everyone seems to be having. 

 

When I import a webpage to a pdf and it automatically makes the fields, the radio button groups all toggle together unless I have one checked by default on the website. 

 

The only other way to not have them all toggle together is to rename the group or fields that is automatically created by Acrobat. 

 

I was thinking of making a script that would go through and rename fields which seems to correct the functionality.

 

However the next issue I have is that rather than using my Group and Field names. Acrobat is appending this long string to the front of the names. ie: 

1vL3RkZi1jcmVhzG12yLnRlc3QvAA==.emp-secondary2-perc

 

Is there something I can do to resolve this issue either via the website form structure or javascript function in acrobat that loops through form fields and just renames them. Or maybe if I can detect this "1vL3RkZi1jcmVhzG12yLnRlc3QvAA==." value before hand I can deduce the names of my fields. 

 

Main thing is this cant be a manual process as the form is too large and too many versions will be created. 

 

Any help? Its a very frustrating issue to have functional code that seems to only work when you "unbreak" it. 

TOPICS
Create PDFs , PDF forms

Views

50

Likes

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 Beginner , Aug 18, 2022 Aug 18, 2022

Appreciate the help, Try67.. Ended up using this. 

for (var i = 0; i < this.numFields; i++) {
    var oFld = this.getField(this.getNthFieldName(i));

    if (oFld.readonly == false && oFld.type == "radiobutton") {
        oFld.value = oFld.value + i
    }
}

 Value wasnt so important to us we just want a form that people can use and print out. 

I basically just swap the value it seems to break the radio button that is actively checked and unchecks them all but then the functionality is intact. (None

...

Likes

Translate

Translate
Community Expert ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

Is that string always the same, or at least the same for all fields in each file?

A script can't actually rename fields, though. What it can do is re-create them (ie. delete the old ones, and add new ones in their place), using the new name. In the process you will lose all actions associated with those fields, but their properties can be kept.

Likes

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 Beginner ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

For the most part, the same radio button groups may or may not be in the pdf. Say there are 5 radio groups. There may sometimes be 4, sometimes 3, sometimes 5. 

 

This is what my current fields look like:

cremadesign_0-1660769584213.png

The radio groups share the same name but different values. Of course you wouldnt be able to tell by that screenshot because of the  menu design...

 

 

Also, its seems that if I toggle any of these 4 options highlighted below: 

cremadesign_1-1660769847144.png

Even if its off and on again, or add a space to the end of the choice, or change the button type to a circle. the functionality returns.

 

Right now I have a basic for loop through every field but I would like to limit it to radio button groups not include text fields. Is there a way to for loop through radio buttons and toggle on of these 4 fields

 

Likes

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 ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

Regarding renaming the fields: You can do it using this (paid-for) tool I've developed:

https://www.try67.com/tool/easily-rename-pdf-fields

Regarding toggling fields on or off: That depends. Toggling them off is easy. Just set their value of "Off".

To toggle them on you need to first select which value to apply. If you don't care which one is selected you can just use the first item in the exportValues array of the field.

Likes

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 Beginner ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

LATEST

Appreciate the help, Try67.. Ended up using this. 

for (var i = 0; i < this.numFields; i++) {
    var oFld = this.getField(this.getNthFieldName(i));

    if (oFld.readonly == false && oFld.type == "radiobutton") {
        oFld.value = oFld.value + i
    }
}

 Value wasnt so important to us we just want a form that people can use and print out. 

I basically just swap the value it seems to break the radio button that is actively checked and unchecks them all but then the functionality is intact. (None selected, click does not toggle entire group. )

Likes

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