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

How to lock a set of radio buttons basing on some selection.

bibhu69
Registered: Apr 28 2010
Posts: 21

Hello All ,

I have got an Acrobat form where there is a radio button . Say 'A' and 'B' . Below Button A there are a set of radio buttons corresponding to set A and the same case is also with set B. The user has to select either A or B first . If he selects A then he has to select one from the radio buttons lying below A . Same case with B. I want to lock the radio button sets of B If the user selects A and vice versa .

The hierarchy goes like this .

A B
1. 1.
2. 2.
3. 3.

So if the user selects A first then he should not be able to select the buttons under B and same case with if he selects B first .

I tried the following script .

var a = this.getField ('A') .value ;
if (a == "value of the button A")

{
this.getField ("field name of the buttons 1,2,3 under set B").readOnly = true ;

}

But this script is of no help . Please suggest a better way.

Thanks.

Bibhu.

My Product Information:
Acrobat Pro 9.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
First of all, the name of the property is "readonly", not "readOnly".
Secondly, where did you place this script? Also, I would change the if statement to something like this:

if (a != null && a != "")That way it doesn't matter which value is selected.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

bibhu69
Registered: Apr 28 2010
Posts: 21
Thanks.

I made it some how . I have placed it in MouseUp event . But there is a problem . If the user clicks A and then click a radio button under it . If after that the user clicks on B then the radio button sets under A becomes readonly . But the selection still persists(which is made under A) over there . So how to reset it when the user clicks B ??

Bibhu .
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Try setting A's value to null, or to "".

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

bibhu69
Registered: Apr 28 2010
Posts: 21
Thanks . Somehow I made it to work . But there is a problem . Even if the user does not select either A or B and if he had selected the choice A previously then the radio buttons under A becomes highlighted(or the choices / radio buttons under B becomes readonly by default) by default . I want no buttons which may be under A or B should be highlighted . I want only the choice A and B should be highlighted . I mean the radio buttons which are either in A or B should not be made readonly by default . And If it is made only it should be allpied to both . Either both readonly or both highlighted when the form opens .

Bibhu.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Sorry, I don't really follow you. Maybe someone else does and can help you out...

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

bibhu69
Registered: Apr 28 2010
Posts: 21
Can you suggest a way to put screen shots ?? If I can then it will be much easier to explain.

Bibhu.
bibhu69
Registered: Apr 28 2010
Posts: 21
Here is the link to the screen shot .https://acrobat.com/#d=CYYlMgtdylcAM2wWpXrciw
The highlighted field option in the acrobat is on .As you can see the radio buttons under A are highlighted when the form is open . But not with the case of B . I would like to make both the set of radio buttons which are under A nad B not highligted when the form opens.And if the user click either A or B , basing upon the selection the radio buttons which are under A or B should be highlighted.

Thanks.

Bibhu .
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You must know the initial state of all fields for this to work. by default, you should start with the sub radio buttons as read only and then set them to read write when the parent button is selected, and you will need to reset or clear and make read only the sub radio buttons of the other button.

You need to make an exclusionary group for the various buttons

Radio buttons in Acrobat Forms never have a value of 'null', the value is one of the export values or a value of "Off" when no button is selected.

So if you have 2 radio buttons named "Parent" with export values of "A" and "B" and then a series of child buttons under them with the buttons under the "A" value button named "ChildA" and the ones under the "B" value button named "ChildB", one could use the following script:
// see if no buttons are checkedif(event.target.value == "Off") {// lock Child A buttonsthis.getField("ChildA").readonly = true;// clear value of Child A buttonsthis.getField("ChildA").value = "Off";// lock Child B buttonsthis.getField("ChildB").readonly = true;// clear value of Child B buttonsthis.getField("ChildB").value = "Off";} // check if "A" button is selectedif(event.target.value == "A") {// unlock Child A buttonsthis.getField("ChildA").readonly = false;// lock Child B buttonsthis.getField("ChildB").readonly = true;// clear value of Child B buttonsthis.getField("ChildB").value = "Off";} // check if "B" button is selectedif(event.target.value == "B") {// unlock Child B buttonsthis.getField("ChildB").readonly = false;// lock Child S buttonsthis.getField("ChildA").readonly = true;// clear value of Child B buttonsthis.getField("ChildA").value = "Off";}

You will need to use this code for the "A" and "B" mouse up action, the mouse enter, and the on focus actions. You may also need to use this code in the on focus action for each of the children, since clearing the form does not reset the read only of the children buttons. Also start with all of the children buttons as read only.

George Kaiser