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

Deselect Radio Button on form in Acrobat 9.0

juliel
Registered: Dec 30 2009
Posts: 15
Answered

Has anyone figured out yet how to deselect a radio button on a form in Acrobat 9.0?
Please do not suggest using check boxes instead of radion buttons. There has to be a way to unclick a button that has been clicked on either by setting something in the properties dialogue box or by running a java script. I've been searching for days and have tested various scripts and have not found one that works.

Please help me.

Thanks!

My Product Information:
Acrobat Standard 9.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
"Radio Button" is like the old mechanical radio buttons on a home console radio or car radio, both prior to digital radios. Once a button is pushed only another can be pushed to disable the first button. So you need a 'reset' button to turn radio button group 'Off' or you can reset the form field.

A 'Mouse Up' action for a button to turn off the radio button group with the name of 'Radio Button1':
this.getField('Radio Button1').value = 'Off';
To reset the field:
this.resetForm('Radio Button1');

George Kaiser

juliel
Registered: Dec 30 2009
Posts: 15
Thanks, but what about when the customer opens the form in Reader or Acrobat, selects one of 2 radio buttons in a group, but then realizes neither one of the 2 should be selected.
For example, I have a form where there are 4 choices (Account 1, Account 2, Account 3, Account 4) to choose from and there are another 3 choices (A-IRA, B-Checking, C-Savings) to choose from under the previous choice #3. Let's say the customer mistakenly chooses C-Checking under #3, but then realizes that he/she needed to choice #2 (Account 2). He/She then wants to unselect choice #3 and C-Checking.
How is that possible?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
A group of Radio buttons (with the same field name) act as a single field. The value of the group is the Export value of the selected Radio Button. There are three ways to deselect the entire group.

1. Perform a Reset operation on the form, or Radio button group.
2. Set the value of the group to "Off". This has to be done from a script, usually from somewhere else on the form, not on any of the Radio buttons in the group. Although this can be done from a MouseUp event on a Radio Button if you really want to do it.
3. Use the "field.checkThisBox()" function to turn a specific Radio Button Off. Again, this has to be done from a script, usually from somewhere else on the form.

All three of these methods are an indirect way of controling the value of a Radio Button Group. The idea behind using a Radio CheckBox group is to give the user a way to directly deselect the group.
From a programming perspective there is only one difference between Radio Buttons and CheckBoxes, i.e., CheckBoxes can be clicked off and Radio Buttons cannot be clicked off.

If you object to using checkboxes for the visual appearance then you can make Radio Button act like check boxes with some scripting. But it's a bit tricky because the script has to have some way to know whether it should be turning the button off, or letting it do it's thing. You need to use a variation of the LiveCycle method given in this article:
http://www.acrobatusers.com/tutorials/creating-radio-checkboxes

Here's what you do.
Add this code to the MouseDown of all the Radio Buttons:event.target.oldVal = event.target.value;
Then add this to the MouseUp of all the Radio Buttons:
if(event.target.oldVal == event.target.value)event.target.value = "Off";

This code catpures the current value of the Radio Button on MouseDown, before the value is changed by the click. If the value has not changed on the MouseUP then the user pressed the same button twice, so the code turns the group off.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
When no radio button is selected the value of the radio button (or buttons with the same name) is 'Off' and when a button is selected the value becomes the export value for the radio button widget (individual button). Each radio button in a group needs to be assigned a unique value. So if you set the value of the radio button group to 'Off' all radio buttons in the group will be unchecked.

Resetting a radio button group resets the group to 'Off' unless one of the buttons is marked to be 'checked' by default, in which case the button with the 'checked' option determines the value of the button.

George Kaiser

juliel
Registered: Dec 30 2009
Posts: 15
Thomp,

Thank you soooo much! That worked!!! You are a java scripting king!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Here's a couple of other solutions:

1. Create a None Radio Button for the group so the user can explictly say they don't want any option selected.
2. Same as #1 except you set the export value of the None button to "Off". Then selecting this button will cause the entire group to be deselected.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script