New User - needs script help
Hi folks, new user here.
Have a text field that I would like to be hidden until one of two radio buttons in a group has been selected. All help greatly appreciated.
Rick S/San Antonio, TX
Hi folks, new user here.
Have a text field that I would like to be hidden until one of two radio buttons in a group has been selected. All help greatly appreciated.
Rick S/San Antonio, TX
You can do this in different ways. Here is one example. Use the following as the custom calculation script in your text field that should be hidden or shown:
var f1 = this.getField("Group1");
var shouldBeVisible = (f1.value != "Off");
event.target.display = shouldBeVisible ? display.visible : display.hidden;
This can be shortened a bit, but shorter code is not necessarily more readable. If you are having problems understanding what's going on here, please review the JavaScript core language syntax. What you need to know is that a radio button group that has no selection will report "Off" as it's value. So the field should be visible when the radio button group is not set to "Off". In that case, we set the event.target.display property (you can find what that means in the Acrobat JavaScript API documentation: Acrobat DC SDK Documentation: event.target ) to display.visible or to display.hidden in the other case (again, more information is in the API documentation).
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.