Skip to main content
Known Participant
November 11, 2020
Answered

Radio Buttons and Fillable Text Fields

  • November 11, 2020
  • 4 replies
  • 7267 views

This is what I am trying to do:

  1. I have 10 text fields which are highlighted blue to show it can be filled in
  2. I have 2 radio buttons, 1st button is for NO and 2nd button is for YES
  3. If you press NO button the 10 text fields are turned off and cannot be filled in and the blue highlight is gone leaving the fields white.
  4. If you press YES button the 10 text fields are turned on and highlighted in blue to show they can now be filled in.

Adobe support tech could not figure out how to turn the 10 text fields on and off. They were only able to turn just 1 text field on or off. After many tries they said it seems as though you can only turn 1 field on or off with 1 radio button. You would need 10 radio buttons to turn the text fields on and off. This makes no sense as Adobe would never design a program that warrants 10 buttons. I requested a higher level tech and was told I could not get one, seriously?

This topic has been closed for replies.
Correct answer ls_rbls
I pasted the code into the java box and got the following error:

SyntaxError: missing } in compound statement
29: at line 30

Last 2 lines of code are:
Property Crime") .readonly =true;
} else {

--
*Lance Brown*
150 Lake Carol Drive
West Palm Beach, FL 33411
T. (561) 686-9679
E. lancebrown13@gmail.com

*(This e-mail was checked by McAfee Virus Scan)*

You're missing the curly braces at the end of that script

 

I will suggest that the easiest way to get this to work for a beginner is to copy this code exactly as it is posted below and paste it in the javascript editor for the first radio button:

 

 

this.getField("Juvenile Address").readonly =true;

this.getField("Juvenile Residence Phone").readonly =true;

this.getField("Juvenile Business Phone").readonly =true;

this.getField("Juvenile Notified By").readonly =true;

this.getField("Juvenile Date").readonly =true;

this.getField("Juvenile Time").readonly =true;

this.getField("Juvenile Disposition").readonly =true;

this.getField("Juvenile Released To").readonly =true;

this.getField("Juvenile Released Date").readonly =true;

this.getField("Juvenile Released Time").readonly =true;

this.getField("Juvenile By Name").readonly =true;

this.getField("Juvenile Reason").readonly =true;

this.getField("Juvenile School Attended").readonly =true;

this.getField("Juvenile Grade").readonly =true;

this.getField("Juvenile Description of Property").readonly =true;

this.getField("Juvenile Value of Property").readonly =true;

this.getField("Juvenile Check Parent").readonly =true;

this.getField("Juvenile Check Legal Custodian").readonly =true;

this.getField("Juvenile Check Other").readonly =true;

this.getField("Juvenile Check Defendant").readonly =true;

this.getField("Juvenile Check Defendant Parents").readonly =true;

this.getField("Juvenile Check Yes 2").readonly =true;

this.getField("Juvenile Check Yes 1").readonly =true;

this.getField("Juvenile Check Yes Property Crime").readonly =true;

this.getField("Juvenile Check No Property Crime").readonly =true;

 

 

Then do the same procedure for this other code; copy and paste it in the other radio button:

 

 

this.getField("Juvenile Address").readonly =false;

this.getField("Juvenile Residence Phone").readonly =false;

this.getField("Juvenile Business Phone").readonly =false;

this.getField("Juvenile Notified By").readonly =false;

this.getField("Juvenile Date").readonly =false;

this.getField("Juvenile Time").readonly =false;

this.getField("Juvenile Disposition").readonly =false;

this.getField("Juvenile Released To").readonly =false;

this.getField("Juvenile Released Date").readonly =false;

this.getField("Juvenile Released Time").readonly =false;

this.getField("Juvenile By Name").readonly =false;

this.getField("Juvenile Reason").readonly =false;

this.getField("Juvenile School Attended").readonly =false;

this.getField("Juvenile Grade").readonly =false;

this.getField("Juvenile Description of Property").readonly =false;

this.getField("Juvenile Value of Property").readonly =false;

this.getField("Juvenile Check Parent").readonly =false;

this.getField("Juvenile Check Legal Custodian").readonly =false;

this.getField("Juvenile Check Other").readonly =false;

this.getField("Juvenile Check Defendant").readonly =false;

this.getField("Juvenile Check Defendant Parents").readonly =false;

this.getField("Juvenile Check Yes 2").readonly =false;

this.getField("Juvenile Check Yes 1").readonly =false;

this.getField("Juvenile Check Yes Property Crime").readonly =false;

this.getField("Juvenile Check No Property Crime").readonly =false;

 

 

Just make sure that both radio buttons are have the same name but chenge the export values. For example, in the first radio button you can leave the export value as "Choice1", and in the second radio button "Choice2".

 

4 replies

JR Boulay
Community Expert
November 12, 2020

In your fields names you should replace the blank space by a dot:

Juvenile.address
Juvenile.residence

Juvenile.phone

etc.

 

So you can reuse my 4 lines script just by replacing "text" by "Juvenile".
It can manage 10, 28 or as much fields as you want at the same time.

Acrobate du PDF, InDesigner et Photoshopographe
sbc707Author
Known Participant
November 12, 2020

Thank you for that. Very much appreciated.

[REMOVED]

sbc707Author
Known Participant
November 24, 2020

I can use your help regarding the Arrest Form you helped me with.
In my laptop the fields that have a dropdown field work fine.
When I send it to the police laptop in the police car which uses acrobat pro dc reader the dropdowns do not work.
Makes no sense. Why does it work in my laptop at home but not in the laptop in the police car.
Not sure if I am explaining this correctly.
Any suggestions?
Lance

JR Boulay
Community Expert
November 11, 2020
Acrobate du PDF, InDesigner et Photoshopographe
sbc707Author
Known Participant
November 11, 2020
That is exactly what I am trying to do. When you click one button all 28
fields will lose the blue highlighting and cannot be filled in. When you
click the other button all the fields will get back the blue highlight and
be able to be filled in. I do not have the javascript but I know where to
put it. I have never did this before so it is all strange to me. This is
actually part of a police arrest form. If the arrest is juvenile then I
need these buttons to work. If the arrest is for adults I need to turn off
the juvenile fields.

Any help would be greatly appreciated. Adobe support said their method
would only turn off and on just one field that I would need 28 ON buttons
and 28 OFF buttons which is insane.

The names of the 28 fields are:

Juvenile Name
Juvenile Address
Juvenile Residence Phone
Juvenile Business Phone
Juvenile Notified By
Juvenile Date
JuvenileTime
Juvenile Disposition
Juvenile Released To
Juvenile Released Date
Juvenile Released Time
Juvenile By Name
Juvenile Reason
Juvenile School Attended
Juvenile Grade
Juvenile Description of Property
Juvenile Value of Property
Juvenile Check Parent - (Check Box)
Juvenile Check Legal Custodian - (Check Box)
Juvenile Check Other - (Check Box)
Juvenile Check Defendant - (Check Box)
Juvenile Check Defendant Parents - (Check Box)
Juvenile Check Yes 2 - (Check Box)
Juvenile Check Yes 1 - (Check Box)
Juvenile Check Yes Property Crime - (Check Box)
Juvenile Check No Property Crime - (Check Box)

--
*Lance Brown*
150 Lake Carol Drive
West Palm Beach, FL 33411
T. (561) 686-9679
E. lancebrown13@gmail.com

*(This e-mail was checked by McAfee Virus Scan)*
try67
Community Expert
November 11, 2020

Basically you can do it with something like this script (use it as the custom calculation script of one of the text fields, or a separate one, it can be hidden, if you wish):

 

if (this.getField("Radio1").valueAsString=="YES") {
this.getField("Text1").readonly = false;

this.getField("Text2").readonly = false;

this.getField("Text3").readonly = false;

} else {

this.getField("Text1").readonly = true;

this.getField("Text2").readonly = true;

this.getField("Text3").readonly = true;

this.resetForm(["Text1", "Text2", "Text"]);

}

 

Adjust the field names as needed.

 

ls_rbls
Community Expert
November 11, 2020

This is handle with Acrobat JavaScripting, not with the Adobe Acrobat's "Show/Hide" built-in feature. So technical support is correct in saying that you're only limited with one selection only but it from the picklist that is offered to the user when they opt to use the "Show/Hide" feature.  They're not correct in suggesting that you need one radio button per each textfield that you want to show or hide.

 

You can achive this with a custom script and use it as a Mouse-up event action. To do so you need to name both radio button fields with the same field name but assigned them with a different export value.

 

Then add a script in the first radio button that will keep every field visible and in the other button add the same script to make them hidden.

 

This is by far the easiest way with some basic JavaScript knowledge.

 

 

Inspiring
November 11, 2020

I think OP wants to make them read only and change background colors not show/hide them.

Although you can use 1 radio button to show/hide multiple fields, just click on add and select 1 field then click again and select another ...etc

sbc707Author
Known Participant
November 11, 2020
I tried doing that by clicking ADD 4 time for 4 different fields and it
only worked for 1 of the fields. Makes no sense. Perhaps it really does
need javascript.

--
*Lance Brown*
150 Lake Carol Drive
West Palm Beach, FL 33411
T. (561) 686-9679
E. lancebrown13@gmail.com

*(This e-mail was checked by McAfee Virus Scan)*