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

Radio Button : How to access in Script ?

zeeshanhashmi
Registered: Jan 2 2008
Posts: 58

Hi

I have 4 radio buttons in my PDF form, and they have all 1 name.

Now in the javascript I want to check which of the 4 radio button is checked ?
I dont want to use the Export Value, i want to do something like this :

var chk = radiobuttons[1].isBosChecked()

please guide

Thanks
Zeeshan

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
The syntax for accessing the 'widget' in the 'isBoxChecked()' is:

Quote:
fieldObject.isBosChecked(nWidget)
Where 'nWidget' is the zero based index to the individual button within the group. Note this number is determined by the order of creation and not the tabbing order. This method will retrun a 'true' value if the widget is checked and a 'false' value if the widget is not checked.

To find which button is checked, you will have to loop through each button in the group.

George Kaiser

zeeshanhashmi
Registered: Jan 2 2008
Posts: 58
Thanks for your reply.

Now the thing is that I have 10 rows, and in each row there are four columns A,B,C,D.
each of the A B C D has 1 radio button. So for example in ROW 1, it is named SET1 in row 2 it is named SET2, and so on.

At the end there is a total field, and I want to count how many of the A are checked, and how many are the B are checked.

Now, How i can access the Radio Button representing A in SET1 ???
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Since is row of buttons have to be in a different exclusionary group, you need to check each group. and determine which widget is checked and then get the export value of that widget field.

If you have each export value for each button set to the column value, you would just need to check the field's value, which I think is far easier.

George Kaiser

zeeshanhashmi
Registered: Jan 2 2008
Posts: 58
okay, thanks a lot Sir, I will just give it a try.

But I just want to know how to reference each button of a same name in javascript ?

like SET1[0] OR SET1[1]
or if there is any index thing like SET1.index(0) ???
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
The 'widget' of check boxes and radio buttons is covered in the Acrobat JavaScript API Reference under the 'Field' object.

Quote:
Beginning with Acrobat 6.0, getField can be used to retrieve the Field object of one individual widget of a field. This notation consists of appending a “.” (period) followed by the widget index to the field name passed. When this approach is used, the Field object returned by getField encapsulates only one individual widget. You can use the Field objects returned this way anywhere you would use a Field object returned by passing the unaltered field name.

George Kaiser