Copy link to clipboard
Copied
I am trying to get a text field to disappear if the value in a different text field is equal to or greater than 21. specifically one text field is titled (”MASTER: age”) another text field is (”under 21 instructions”) the third is (”over 21 instructions”). (”MASTER: age”) is automatically calculated based off the date of birth entered in a separate text field.
If (”MASTER: age”)is 21 or older I want (”under 21 instructions”)to disappear & (”over 21 instructions”) to appear.
If (”MASTER: age”)is 21 or older I want (”under 21 instructions”)to appear & (”over 21 instructions”) to disappear.
What text field should I attach the code to, and what code is needed. Everything I've tried so far has not worked.
Hi,
You can try something like this (it worked on my end):
//Place this code on the Custom Format Script of the "MASTER: age" field
var master = this.getField("MASTER: age").value;
if (master == "")
{
getField("under 21 instructions").display=display.hidden;
getField("over 21 instructions").display=display.hidden;
}
else if (master >= 21)
{
getFie
...
Copy link to clipboard
Copied
Hi,
You can try something like this (it worked on my end):
//Place this code on the Custom Format Script of the "MASTER: age" field
var master = this.getField("MASTER: age").value;
if (master == "")
{
getField("under 21 instructions").display=display.hidden;
getField("over 21 instructions").display=display.hidden;
}
else if (master >= 21)
{
getField("under 21 instructions").display=display.hidden;
getField("over 21 instructions").display=display.visible;
}
else if (master <= 20)
{
getField("under 21 instructions").display=display.visible;
getField("over 21 instructions").display=display.hidden;
}
Place the in the "MASTER: age" field custom format script as shown in the slide below:
Copy link to clipboard
Copied
Worked like a charm, thank you for the help.
Copy link to clipboard
Copied
You're welcome.
Copy link to clipboard
Copied
Here's an article on exactly this topic:
https://acrobatusers.com/tutorials/show_hide_fields/
Copy link to clipboard
Copied
Hi There:
I am trying to do something similar to the above. I set up a javascript based on this thread but I have a sytax error on line 10 and cannot for the life of me figure out what I have done wrong. The file is set up so that when a user types in one of three different dividend rates, the correct Annual Percentage field will appear. It's probably something really stupid since I don't do this very often. I am attaching the plain text file I have made.
Copy link to clipboard
Copied
Next time please use the code box to post your code.
One error is that "%" is not a valid character for a number. remove it.
Another error in the code (but isn't something that would be reported) is that the "=" character is for assigning a value. Use "==" for comparisons.
Copy link to clipboard
Copied
Thanks so much Thom.
I realized I did not have some field names correct, so I did that and this is now my code (the correct name of the field I am trying to add this to is "Dividend Rate"--Problem being that there is a sytanx error in line 3 or 4, but I can't figure it out. Can you please help me out again?
var master = this.getField("Dividend Rate").value;
if (Dividend Rate = "")
{
getField("APY-TW").display=display.hidden;
getField("APY-TWP").display=display.hidden;
getField("APY-TFA").display=display.hidden;
}
else if (Dividend Rate = 3.920)
{
getField("APY-TW").display=display.visible;
getField("APY-TWP").display=display.hidden;
getField("APY-TFA").display=display.hidden;
}
else if (Dividend Rate = 4.400)
{
getField("APY-TW").display=display.hidden;
getField("APY-TWP").display=display.visible;
getField("APY-TFA").display=display.hidden;
}
else if (Dividend Rate = 4.880)
{
getField("APY-TW").display=display.hidden;
getField("APY-TWP").display=display.hidden;
getField("APY-TFA").display=display.visible;
}
Copy link to clipboard
Copied
Again, the "=" character is for assignment, not comparison.
But the error is on the line
if (Dividend Rate = "")
Dividend Rate is not a legal name for a variable, because it contains a space. But I think you meant to use the variable you defined in the first line that is assigned the value of the "Dividend Rate" field.
The line should be this.
if (master == "")
Also, always prefix getField() with the this keyword.
this.getField("...")