Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Radio Button choice displays answer in text field box

Explorer ,
Mar 16, 2025 Mar 16, 2025

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.
DateResults.JPGDateJavascript.JPG

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

TOPICS
JavaScript
261
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 17, 2025 Mar 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 = "";}

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2025 Mar 16, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2025 Mar 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 = "";}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2025 Mar 17, 2025

That's did not work.  When the first button was chosen it enter YES.  When chosen the other two left the box blank.  Again, I need the box to show, whatever button was chosen.  See pics for details.WrongScript.jpgCorrectScript.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2025 Mar 17, 2025

You said your choices were 1st/month, 3rd/month, 10th/month.  Change your export values to these and it will work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2025 Mar 17, 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, yours as:

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 = "";}

 

and Nesa's script as:

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 = "";}

 

Still the same result.  Only 1st box shows correctly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2025 Mar 17, 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 = "";}

 

 

Still the same result.  Only 1st box shows correctly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2025 Mar 17, 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 = "";}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2025 Mar 17, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2025 Mar 17, 2025

I guess I am not understanding. When using just that script, nore of my radio buttons show anything in my box. all 3 radio buttons leaves a blank response in the box.  That's why I added your script to hers. At least the first radio button does right.  Whatever I am doing wrong, please show me and advance me the correct script to make this work.  I am about to lose this contract because I can't get this script right.  Thanks.WrongScript2.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2025 Mar 18, 2025
LATEST

Your form did not upload properly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2025 Mar 17, 2025

This was the correct answer.  User error was the issue. I found out that I had a script attached to the other 2nd and 3rd Buttons.  That's why they were blank when ticking them.  Deleted both of those scripts from the buttons and Viola! It worked for all three choices. You rock, Nesa!! Thanks for assisting me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines