Copy link to clipboard
Copied
Hello,
We have a document that works already but needs to add some verabage and i cannot edit the exiting document and i am having to recreate it. The current form works this way but I am trying to do a very simple Radio Buttion option and depending on what option they choose, some fields will appear and others will stay hidden. I am attempting to you this code:
{
// Get the selected value from the radio button group
var selectedValue = this.getField("Selection").value;
// Get the field that will be shown/hidden
var textField = this.getField("Payee Name");
// Show or hide the field based on the selected radio button value
if (selectedValue == "Paper Check") {
textField.display = display.visible; // Show the field
} else if (selectedValue == "ACH") {
textField.display = display.hidden; // Hide the field
} else {
// Optionally, hide the field if no selection is made
textField.display = display.hidden;
}
}
But this is not working. I would like to be able to include all fields that would either disappear or be visible into one script to keep things neat. Thanks in advance
Copy link to clipboard
Copied
That should work as long as the radio button export values are exactly as written. Also, where is this script. If it is in the "Payee Name" field, this.getField("Payee Name") should be change to event.target first and last curly braces should be removed. If "Paper Check" is the only value where the field will be visible you don't need the else if statement. Just use this:
if(this.getField("Selection").value=="Paper Check")
{event.target.display=display.visible}
else
{event.target.display=display.hidden}
Copy link to clipboard
Copied
Hello,
One of the fields i want to is "payee name" when "paper check" is selected. The other field "merchant name" is to be shown when "ACH" is selected and the "payee name" would be hidden again. I have this script placed radio button group labled "selection." When i run this neither field shows or hides.
Copy link to clipboard
Copied
You would have to use a mouse up action in all radio buttons. Instead use the following custom calculation script an another text field, not the 2 mentioned:
var pn=this.getField("payee name");
var mn=this.getField("merchant name");
pn.display=display.hidden;
mn.display=display.hidden;
if(this.getField("selection").value=="paper check")
{pn.display=display.visbile}
if(this.getField("selection").value=="ACH")
{mn.display=display.visible}
Note that all export values and field names are case sensitive. Make sure they match exactly.
Copy link to clipboard
Copied
So main the issue i found was me not typing exactly the name of the field, so THANK YOU for that catch. Follow up question now. For the rest of the fields, i would just copy the same script and replace the names with the fields that will need to populate? or is the script you provided the best used one? I am using mouse up for the action btw.
Copy link to clipboard
Copied
Also, I currently have the script in the "paper check" and "ACH" which is the radio group buttons themselves or should it be in the "selection" which is the parent name of the radio group?
Copy link to clipboard
Copied
Remove the scripts from every field except a text field that is not any of the fields in the script.
Copy link to clipboard
Copied
Awesome. Thank you so much!!