@Thom Parker I couldn't actually get yours to do anything. But I managed to isolate somthing here.
Here are my two scripts. Now I've tried inserting my "Textbox Tadio Button Choice" script right in my concat script where you would see: this.getField("FieldB.0").valueAsString
//Textbox Radio Button Choice
var a = this.getField("Group5").valueAsString;
var b = this.getField("FieldB.0").valueAsString;
var c = this.getField("FieldB.1").valueAsString;
if (a=="Choice1") event.value = b;
else if (a=="Choice2") event.value = c;
else event.value = "";
//Concat script
var s = "The quick " +
this.getField("FieldA").valueAsString +
" fox " +
this.getField("FieldB.0").valueAsString +
" over the " +
this.getField("FieldC").valueAsString +
" dog. ";
event.value = s.replace(/^, |, $/g, "");
//My Dumba$$ Script
var a = this.getField("Group5").valueAsString;
var b = this.getField("FieldB.0").valueAsString;
var c = this.getField("FieldB.1").valueAsString;
var s = "The quick " +
this.getField("FieldA").valueAsString +
" fox " + {
if (a=="Choice1") event.value = b;
else if (a=="Choice2") event.value = c;
else event.value = "";
}
+
" over the " +
this.getField("FieldC").valueAsString +
" dog. ";
event.value = s.replace(/^, |, $/g, "");
I've tried brackets and everything I could think of, googled it. I feel like I am right there at the precipice of figuring it out. Am I deluded or am I on the right track? I do get errors when I put that in there like that.
Well I didn't include several bits, so my script was not complete. I was riffing off of your original script, and just showing how to use the radio buttons to select a text component. I've included the missing bits below. But it's still a pretty simple script. And is essentially the same thing you've presented above, but code correct.
For example, the replace function in this line doesn't do anything.
event.value = s.replace(/^, |, $/g, "");
However, this is not an error. The code just returns the value in "s", essentially ignoring the replace function.
Also, in the rewrite of the script below "//My Dumba$$ Script ". You have put an if statement inline with the string concatonation statement. This is incorrect syntax, and does report an error.
I think you would find it helpful to learn about using the Console Window, which is where errors are reported.
https://www.pdfscripting.com/public/images/video/AcroJSIntro/AcroJSIntro_ConsoleWindow.cfm
If you'd like to learn a bit about scripting fields in Acrobat you'll find the basics discussed here:
https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm
Here's the correct, and complete code for the Custom Calculation script.
var strText = "The quick " + this.getField("FieldA").value + " fox ";
if(this.getField("Group5").value == "Choice1")
strText += this.getField("FieldB.0").value;
else
strText += this.getField("FieldB.1").value;
strText += " over the " + this.getField("FieldC").value + " dog";
// This line puts the concatonated string into the field value.
event.value = strText;