Copy link to clipboard
Copied
Hi, I am a forms designer and have recently been asked to make one of my client's forms fillable. I have purchased Adobe 9 Pro and everything was going quite well until I ran into an area that requires radio buttons.
It would seem that once a radio button is selected, it cannot be deselected, you can only move from one radio button to another.
Can anyone tell me how to deselect radio buttons or if it is even possible?
Thanks!
You can reset the form, but then you will lose all the data in it.
If a radio button needs to be deselected, it should probably be a check-box.
Copy link to clipboard
Copied
You can reset the form, but then you will lose all the data in it.
If a radio button needs to be deselected, it should probably be a check-box.
Copy link to clipboard
Copied
Thanks Try67...I appreciate your help
Copy link to clipboard
Copied
Hi highviewgb,
You can have a set of checkboxes that act as a radio button group. Here is an article on that-
http://www.acrobatusers.com/tutorials/creating-radio-checkboxes
Another possibility often used is to add a radio button for "none" in the group in case a choice is made and then the user decides it is not correct.
Hope this helps,
Dimitri
WindJack Solutions
Copy link to clipboard
Copied
Dimitri, that is exactly what I was looking for....thank you so much!!!!!!!
Copy link to clipboard
Copied
Hello,
sorry for reopenning topic.
I also needed to deselect radio-buttons and I found this thread while I was searching forum.
I wrote function inspired by article from DimitriM's link and I would like to share it with those, who will search it in future.
Tested in AR 9.3 and 8.0.
//1. I have this in script object called eg "foo"
var rbs = new Object();
function handleRBClick(o)
{
if (rbs[o.name]==null)
{
rbs[o.name]=o.rawValue;
}
else{
if (rbs[o.name] == o.rawValue)
{
o.selectedMember().rawValue = 0;
o.execEvent('change');
}
rbs[o.name] = o.rawValue;
}
}
//2. then add following to your radio-button's group click() event
foo.handleRBClick(this);
//so it needs one handleRBClick call for each radio-button group, but it is still better then placing it to each group item.
Copy link to clipboard
Copied
Is your code looks like it for a form created using LiveCycle Designer and can not be used in forms created with Acrobat's form tools. Acrobat JavaScript does not have a property of ".rawValue".
LiveCycle Designer is a different program than Acrobat and uses different JavaScript language syntax and also has a additional scripting language, FormCalc.
Copy link to clipboard
Copied
You are right GKaiseril, I unfortunately noticed it now, it should be for LiveCycle forms thread.
Sorry. If there are moderators, it can be deleted.
Copy link to clipboard
Copied
Nice scripting Radek.
I took the liberty of evolving foo into the following:
var rbs = new Object();
function handleRBClick(o) {
if (rbs[o.name] == o.rawValue) {
o.selectedMember().rawValue = null;
}
rbs[o.name] = o.rawValue;
}
Also, you might want to add the call foo.handleRBClick(this) to the exclGroup's init-event in order to handle opening data files.
Copy link to clipboard
Copied
Nice modification c@tc.se ( I feel a bit embarrassed, I usually do not write this redundancy 🙂 )
I do not remember, why exactly I needed to force the execEvent('change'), but It may not work properly without it.
Thanks for posting.
radek
Copy link to clipboard
Copied
Nice modification c@tc.se ( I feel a bit embarrassed, I usually do not write this redundancy 🙂 )
Don't! 😆
I had to go make a diagram of your if-statements in order to spot ways to optimize it.
I went through lengths trying to solve the problem using no scripting at all; I figure text field events contain the states of the field before and after the change. However check buttons seem to be a different story.
I thought the line:
if (rbs[o.name] == o.rawValue)
would yield an exception the first time (addressing an undeclared array index). For some reason it doesn't.
Anyway, here's an improved, encapsulated, singletonish, namespace-aware version:
var handleRBClick = function() {
var rbs = new Object();
return function(o) {
if (rbs[o.name] == o.rawValue) {
o.selectedMember().rawValue = null;
}
rbs[o.name] = o.rawValue;
};
}();