Copy link to clipboard
Copied
I have 2 radio button options and 4 text boxes (on my form that are related). When the first is selected, I want only one text box below to appear. When the second is selected, I want the 3 remaining text boxes to appear. I have tried so many different codes, but cannot get it to work. When I use a traditional action to show/hide a field, when one radio button is selected, the text boxes disappear and can't be brought back (they remain hidden). I'm trying to use javascript. Any help is appreciated!
You will need to name the buttons and fields consistently
Say the button is called Button and the choices are R1 and R2.
Call the fields Field1, Field2, Field3, Field4.
var Q = this.getField("Button");
var A = this.getField("Field1");
var B = this.getField("Field2");
var C = this.getField("Field3");
var D = this.getField("Field4");
if (Q.value === "R1") {
A.hidden = false;
B.hidden = true;
C.hidden = true;
D.hidden = true;
}
if (Q.value === "R2") {
A.hidden = true;
...
Copy link to clipboard
Copied
Post what you've tried and list the exact field names of all of the fields involved.
Copy link to clipboard
Copied
Thank you. Below are the scripts I tried.
1.
this.getField("Annual Amount").display = (event.target.value=="Annually") ? display.visible : display.hidden;
this.getField("Fall Amount").display = (event.target.value=="Semesterly") ? display.visible : display.hidden;
this.getField("Spring Amount ").display = (event.target.value==" Semesterly ") ? display.visible : display.hidden; this.getField("Summer Amount ").display = (event.target.value==" Semesterly ") ? display.visible : display.hidden;
2.
{ var a = this.getField("Distribution").value;
function ShowMe()
if (a == "Annually")
{ this.getField(“Fall Amount").display = display. hidden;
this.getField(“Spring Amount").display = display.hidden;
this.getField(“Summer Amount").display = display.hidden; }
3.
if (this.getField("Annually").value=="Yes") {
this.getField("Fall Amount").readonly = true;
this.getField("Spring Amount").readonly = true;
this.getField("Summer Amount").readonly = true;}
4.
var v = this.getField("Distribution").valueAsString;
this.getField("Annual Amount").display = (v=="Semesterly") ? display.visible : display.hidden;
this.getField("Fall Amount").display = (v=="Annually") ? display.visible : display.hidden;
this.getField("Spring Amount").display = (v=="Annually") ? display.visible : display.hidden;
this.getField("Summer Amount").display = (v=="Annually") ? display.visible : display.hidden;
5.
var f = this.getField("Annual Amount");
f.hidden = (Annually=off);
Copy link to clipboard
Copied
You will need to name the buttons and fields consistently
Say the button is called Button and the choices are R1 and R2.
Call the fields Field1, Field2, Field3, Field4.
var Q = this.getField("Button");
var A = this.getField("Field1");
var B = this.getField("Field2");
var C = this.getField("Field3");
var D = this.getField("Field4");
if (Q.value === "R1") {
A.hidden = false;
B.hidden = true;
C.hidden = true;
D.hidden = true;
}
if (Q.value === "R2") {
A.hidden = true;
B.hidden = false;
C.hidden = false;
D.hidden = false;
}
you need the code to be on both radio buttons, i would put them on the Mouse Release
You can also affect the required in the same way as the hidden property (but remember having it hidden and required leads to frustration)
Hope that helps
Copy link to clipboard
Copied
Thank you Lukas! It worked!!!
Copy link to clipboard
Copied
Keeping all the variables in the beginning makes it easier to reuse and trouble shoot