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

"Off" result when Radio button not selected

andrewchow11
Registered: Mar 28 2011
Posts: 20

Hello all,

In Acrobat form javascript,
I created 2 CheckBox(CB1 and CB2),
CB1 to involve 3 RadioBox(RB1a, RB1b and RB1c),
CB2 to involve 3 RadioBox(RB2a, RB2b and RB2c).

(ok)
If you press "ON" CB1, the RadioBox(RB1a, RB1b and RB1c) can be choose.
And the CB2, and RadioBox(RB2a, RB2b and RB2c) is Readonly and "OFF".
 
Conversely,
 
(ok)
If you press "ON" CB2, the RadioBox(RB2a, RB2b and RB2c) can be choose.
And the CB1, and RadioBox(RB1a, RB1b and RB1c) is Readonly and "OFF".
 
(ok)
If you do not press "ON" the CB1 and CB2,
then RadioBox(RB1a, RB1b, RB1c, RB2a, RB2b, RB2c) is Readonly and "OFF".
 
(ok)
If CB1 press "ON" and choose RB1b,
after that, CB1 "ON" directly change CB2 "ON", RB1b has been eliminated.
  
In CheckBox1 script
===============================================
if (this.getField("CB2").value=='0') {
this.getField("RB1").readonly = false;
this.getField("RB2").readonly = true;
this.getField("RB2").value = '';
} else {
this.getField("RB1").value = '';
this.getField("RB1").readonly = true;
}
  
In CheckBox2 script
===============================================
if (this.getField("CB2").value=='1') {
this.getField("RB2").readonly = false;
this.getField("RB1").readonly = true;
this.getField("RB1").value = '';
} else {
this.getField("RB2").value = '';
this.getField("RB2").readonly = true;
}
    
But why I create "Textbox1" to get Radiobox value, the results display "Off" in textbox1??
  
In Textbox1 script
===============================================
if (this.getField("CB2").value=='0') {
event.value = this.getField('RB1').value;
} else {
event.value = this.getField('RB2').value;
}
   
Pls help how to solve this problem, thanks a lot!
 

My Product Information:
Acrobat 9.0, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You might want to to name the check boxes and radio buttons can work together as an 'exclusionary group' which allows only one button in the group to be selected at a time. You need to name the buttons you want grouped with the same name and give each individual button a different 'Export Value'. When none of the check boxes or radio buttons in a group, the value for the group is "Off". If you want to uncheck a group, you can either reset the group name of set the value of the group to "Off".

George Kaiser

andrewchow11
Registered: Mar 28 2011
Posts: 20
Hello gkaiseril,

Thanks for you reply. In "Textbox1", how can display "Off" change to display ""??

Please help me.


try67
Expert
Registered: Oct 30 2008
Posts: 2398
Add an if statement to check if the value is "Off", and if so apply the value "" instead of the field's value.

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

andrewchow11
Registered: Mar 28 2011
Posts: 20
I have added an if statement to check if the value is "Off",
but is not improve, how to modify it?


In Textbox1 script
===============================================
if (val !== "Off") {
event.value = this.getField('RB1').value;
event.value = this.getField('RB2').value;
} else {
event.value = "";
}

if (this.getField("CB2").value=='0') {
event.value = this.getField('RB1').value;
} else {
event.value = this.getField('RB2').value;
}

try67
Expert
Registered: Oct 30 2008
Posts: 2398
I don't understand your code. What are you trying to achieve in Textbox1?

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

andrewchow11
Registered: Mar 28 2011
Posts: 20
yes, in Textbox script, but display "Off" result when Radio button not selected(no effect),I need to change "Off" display to "" display... :(

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Instead of using the strict "not equal to" (must match value and type) try the more relaxed operator "!=" (values not equal).

From MDC JavaScript Reference:

!= Returns true if the operands are not equal.
!== Returns true if the operands are not equal and/or not of the same type.

George Kaiser