These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Radio Buttons - Self Updating Text Field

sand510
Registered: Mar 24 2009
Posts: 6
Answered

Hello, I searched through this forum and I wasn't quite able to find the solution for my problem.

I am trying to create a pdf form with radio buttons for options that the user can pick. There are basically 4 groups of radio buttons with two button values for each group.

Group 1 - Option A/Option B
Group 2 - Option C/Option D
Group 3 - Option E/Option F
Group 4 - Option G/Option H

Based on the different combinations, a textfield is updated... "txtSortedOption"...

How can I get "txtSortedOption" to update itself if the user decides to change from Option C to Option D? Do all instances and options have to be hard coded into each button code?

I currently have it such that if you select Option A button, it changes "txtSortedOption" to a specific value, and so forth as you go down... this is not the best way... I am hoping for a way to have "txtSortedOption" to determine it's value based on the selected group values.

Thank You,
SanD

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
If you just use a custom calculation script for the "txtStoredOption" to combine all the values of the 4 Radio Button groups. Since you have not indicated the product used to create the form, Acrobat (AcroForms) or LiveCycle Designer (XML), an specific coding can not be provided due to differences in syntax.

You can use a JavaScript array and the "join()'" method to create a result value. You can write a script to concatenate the field's values and drop unselected options. Or write a function that can concatenate up to 3 fields with an optional delimiter and this function can adjust for missing values.

George Kaiser

sand510
Registered: Mar 24 2009
Posts: 6
I am using Acrobat 9 Pro Extended (AcroForms). Where would I write these scripts? Does AcroForms allow me to view the entire source code?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
In Acrobat JavaScripts exists in many places depending upon what object and action they are attached to.

Under the "Advanced => Document Processing => JavaScript" there is an option to "Edit All JavaScripts", but you really need to know what you are doing because of special codes.You may want to review Thom's JavaScript tutorials and the eSeminars on demand.

A simple custom script for the text field could be:
// create an array for the Radio Button valuesvar Group = new Array() // populate the arrayGroup[0] = this.getField("Group1").value;Group[1] = this.getField("Group2").value;Group[2] = this.getField("Group3").value;Group[3] = this.getField("Group4").value; // null out 'Off' valuesfor(i in Group) {if(Group[i] == 'Off') Group[i] = '';} // end null Off values // join the elements of the array for the field valueevent.value = Group.join(', ');

George Kaiser