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

Help, adding Text to a text field using radio buttons!

Community Beginner ,
Sep 03, 2017 Sep 03, 2017

Hi guys and thank you for your answers!

I have about 8 radio buttons in same group that intent to target only one Text field, so depending on user choice the Text field have a different text, how can I accomplish this using Javascript instead of creating 8 different Text fields/Default Values.

radiob.jpg

Thank you for your answers!

I tried:

var f = this.getField("Target");

f.value = util.printd("This is a dummy text, This is a dummy text, This is a dummy text "());

but obviously didn't work! 

TOPICS
Acrobat SDK and JavaScript
960
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

correct answers 1 Correct answer

Community Expert , Sep 04, 2017 Sep 04, 2017

Ah, that requires a different approach. In that case you will need to use something like this as the Mouse Up event of each radio-button:

this.getField("Target").value = "Some text for option 1";  // script for the first button


this.getField("Target").value = "Some text for option 2";  // script for the second button

this.getField("Target").value = "Some text for option 3";  // script for the third button

Translate
Community Expert ,
Sep 03, 2017 Sep 03, 2017

As the custom calculation script of the text field enter something like this:

var rdValue = this.getField("Radio1").valueAsString;

if (rdValue=="Off") event.value = "";

else if (rdValue=="Choice1") event.value = "Some text for option 1";

else if (rdValue=="Choice2") event.value = "Some text for option 2";

else if (rdValue=="Choice3") event.value = "Some text for option 3";

// etc.

Adjust the script to contain the correct field names, values and texts, of course.

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 Beginner ,
Sep 03, 2017 Sep 03, 2017

Ohhh, Myyyyy  ohhh, myyyyy!!

Totally correct!!

Works beautiful!!!   Thank you so much!!!! 

A

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 Beginner ,
Sep 04, 2017 Sep 04, 2017

Wait a second... please...

I wanted to use the target text field as samples so the user knows what to write, maybe just changing a few words and people names, but when you edit the text field and click away it goes back to the original text, doesn't save the new text! 

How can this be accomplished???? please help!!! 

I thought it was ready!! 

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 ,
Sep 04, 2017 Sep 04, 2017

Ah, that requires a different approach. In that case you will need to use something like this as the Mouse Up event of each radio-button:

this.getField("Target").value = "Some text for option 1";  // script for the first button


this.getField("Target").value = "Some text for option 2";  // script for the second button

this.getField("Target").value = "Some text for option 3";  // script for the third button

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 Beginner ,
Sep 05, 2017 Sep 05, 2017
LATEST

It's working!

-----------------------------------------------------------------------------------------------------------------

One last question, while finishing this form:

I have 18 Radio Buttons and only the first one have sub-menu (4 Buttons) that show only if that Rd1 is checked.

This is what I did:

Rd1: this.getField("Buttons").display = display.visible;

Rd2: this.getField("Buttons").display = display.hidden;

Rd3: this.getField("Buttons").display = display.hidden;

Rd4: this.getField("Buttons").display = display.hidden;

Rd5: this.getField("Buttons").display = display.hidden;

Etc....(to Rd18)

It's works, but I feel It should be a better way to do it.

So I tried these:

if(event.target.value =="Yes"){

this.getField("Buttons").display = display.visible;

}

else {

this.getField("Buttons").display = display.hidden;

}

But it's doesn't work!

I also tried "On blur,  this.getField("Buttons").display = display.hidden;", but when I click on a button, all 4 go hidden,

showhide.jpg

So my question is: Is there a short code to be place only on RB1 and get the same result as I have it working now?

Thank you so much!!!

I appreciate your help!

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