Skip to main content
Known Participant
March 17, 2025
Answered

Radio Button choice displays answer in text field box

  • March 17, 2025
  • 2 replies
  • 829 views

I am trying to do a simple task, but keep running into a brick wall.  I need my client to select 1 radio choice out of 3 buttons, and have whatever choice the tic, display in a text boxt at the end of the road, automatically.  My radio group is called Payment Date.  The 3 choices are: 1st/month, 3rd/month, 10th/month.  That is the actual name of my three options too.  Whichever chosen needs to appear in the text box as the same wording.  I have tried several calcualtion scripts but it only shows the first option.  I don't know how to add the other two, so they will show when chosen.  Last script attempted below.  See pics for details.

var showField = (this.getField("Paymentdate").valueAsString=="Yes")
if (showField) event.target.display = display.visible;
else {event.target.display = display.hidden; event.value = "1st/month";}

Correct answer Nesa Nurani

As mentioned by @PDF Automation Station you need to pay attention to field name.

Also, if yours choices are "1st/month, 3rd/month, 10th/month" there is no "Yes" choice then.

If you wish to 'show' text field and display value from radio button that is selected, use this as custom calculation script of that text field:

var showField = this.getField("Paymentdate").valueAsString;

if(showField !== "Off") {
 event.target.display = display.visible;
 event.value = showField;}
else {
 event.target.display = display.hidden; 
 event.value = "";}

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
March 17, 2025

As mentioned by @PDF Automation Station you need to pay attention to field name.

Also, if yours choices are "1st/month, 3rd/month, 10th/month" there is no "Yes" choice then.

If you wish to 'show' text field and display value from radio button that is selected, use this as custom calculation script of that text field:

var showField = this.getField("Paymentdate").valueAsString;

if(showField !== "Off") {
 event.target.display = display.visible;
 event.value = showField;}
else {
 event.target.display = display.hidden; 
 event.value = "";}
Known Participant
March 18, 2025

I did. Just verified my export values are correct.  The first radio button works fine. but the second and third button is still showing a blank box.,  I tried both options, your script:

 

var showField = this.getField("Paymentdate").valueAsString;

if(showField !== "Off") {
event.target.display = display.visible;
event.value = showField;}
else {
event.target.display = display.hidden;
event.value = "";}

 

 

And PDF Automation script:

this.getField("Paymentdate").value=="Off"?event.value="":event.value=this.getField("Paymentdate").value;

if(showField !== "Off") {
event.target.display = display.visible;
event.value = showField;}
else {
event.target.display = display.hidden;
event.value = "";}

PDF Automation Station
Community Expert
Community Expert
March 18, 2025

You don't need to hide anything with my script because if the value is "Off" it won't show anything.  If the value is anything else, it will show the export value.  You only need this line:

this.getField("Paymentdate").value=="Off"?event.value="":event.value=this.getField("Paymentdate").value;

The rest of the script is going to throw an error because you are mixing both scripts together.  Mine does not have a variable named showField.  You can set the field to Read only so no one can type in it.  If the first one works the others should work but you have to change the field name of Paymentdate.

PDF Automation Station
Community Expert
Community Expert
March 17, 2025

this.getField("Paymentdate").value=="Off"?event.value="":event.value=this.getField("Paymentdate").value;

Your description says the field is called Payment Date, but you called it Paymentdate in your script.  Use the correct one with the script above.  No need to show/hide the text field.