Copy link to clipboard
Copied
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.
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!
1 Correct answer
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 buttonthis.getField("Target").value = "Some text for option 3"; // script for the third button
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Ohhh, Myyyyy ohhh, myyyyy!!
Totally correct!!
Works beautiful!!! Thank you so much!!!!
A
Copy link to clipboard
Copied
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!!
Copy link to clipboard
Copied
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 buttonthis.getField("Target").value = "Some text for option 3"; // script for the third button
Copy link to clipboard
Copied
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,
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!

