Copy link to clipboard
Copied
I am trying to use three form fields to populate one that will be identical at the top of each following page; Name, Position, and Employee ID. i have tried several scripts found with minor modifications but have not been able to make it work. On the first page I have the fields listed above to be entered and for our records keeping it is required at the top of every page. What would be the best method of completing this?
You need to provide more information regarading exactlyhow you want to construct the output from the three input values. An example would be helpful, for example:
Name: Jimmy Buffett
Position: Musician
Employee ID: A1A
Output: Jimmy Buffett, Musician, A1A
For the particular format in the above example, the custom calculation script of the single field at the top of the pages could be as simple as:
event.value = getField("NAME").valueAsString + ", " + getField("POSITION").valueAsString + ", " + getFiel
...Copy link to clipboard
Copied
You need to provide more information regarading exactlyhow you want to construct the output from the three input values. An example would be helpful, for example:
Name: Jimmy Buffett
Position: Musician
Employee ID: A1A
Output: Jimmy Buffett, Musician, A1A
For the particular format in the above example, the custom calculation script of the single field at the top of the pages could be as simple as:
event.value = getField("NAME").valueAsString + ", " + getField("POSITION").valueAsString + ", " + getField("EMP_ID").valueAsString;
but with the actual field names that you've chosen. It would be slightly more complicated if you wanted to gracefully deal with blank values, but this might get you started.
Copy link to clipboard
Copied
This worked perfectly, Thanks.
Copy link to clipboard
Copied
Hi George,
I was looking for a solution to combining multiple fields into one and your answer above was very helpful!! However, I'm wondering how I can use your script above but skip blanks? Thanks in advance!
Copy link to clipboard
Copied
That requires a different approach. Try this code:
var fields = ["Text1", "Text2", "Text3"]; // Replace with actual field names
var values = [];
for (var i in fields) {
var v = this.getField(fields[i]).valueAsString;
if (v!="") values.push(v);
}
event.value = values.join(", ");