Copy link to clipboard
Copied
Hello everyone, I'm trying to create a group of fields that would have pre-populated text in the export value. Then combine those fields into one, which would make a complete sentence (or paragraph) of those field values. For example, Field1 would have "We propose to install". Then in Field2 would have the (total footage) "of 8' high CLF". In Field3 would have the total footage then "8' high WIF". In Field3 would have pretty much the same but this would be "of 8' high Wood Fence". Giving me the choice to show/hide the particular fields.
Is this something that can be done using javascript? I don't know enough but I'd like to learn. Or, does anyone know of a way to accomplish something like this in a PDF. I'd like to create a short cut to be able to put the combinations into a job description. If you can show me how to create the first one, then I can do the rest. Thank you all so much.
Sure. In the code, change all instances of "valueAsString" to "defaultValue".
Copy link to clipboard
Copied
Yes, this is easily done. You can use something like this as the custom calculation script of the final field:
event.value = this.getField("Field1").valueAsString + this.getField("Field2").valueAsString + this.getField("Field3").valueAsString;
Copy link to clipboard
Copied
Heya Gilad, thanks for the quick response. The script works, but only when I type some text into the field. What I would like to do is not have to type and have the text filled in the default value of each text field and have that text fill into the end text field. I'll probably hide the fields and only show them when needed. Can that be done?
Copy link to clipboard
Copied
I don't understand what you mean... You want to combine the default values, not the actual values?
Copy link to clipboard
Copied
Yes. Is that possible? The Text Field Properties window. Options > Default Value. I have just typed in some text there and it doesn't change.
Copy link to clipboard
Copied
Sure. In the code, change all instances of "valueAsString" to "defaultValue".
Copy link to clipboard
Copied
Right on the money. Thanks, Gilad. That was perfect. Now for part 2. I would like the default values to populate into the destination text field only if one or all 3 text fields are visible.
Copy link to clipboard
Copied
You can use something like this, then:
var f1 = this.getField("Field1");
var f2 = this.getField("Field2");
var f3 = this.getField("Field3");
if (f1.display==display.visible || f2.display==display.visible || f3.display==display.visible)
event.value = f1.defaultValue + f2.defaultValue + f3.defaultValue;
else event.value = "";
Copy link to clipboard
Copied
Interesting. I'll have to play around with it later. You definitely know your stuff. Thanks for all your time.