I have the javascript on Button21. In the Properties>Actions Tab Mouse Down trigger, Run Java Script is the action. I hope this helps.
OK. You should use Mouse Up instead, and the script could be changed to:
// Mouse Up script for a button
(function () {
// Get the field values, as strings
var sEvent = this.getField("Event").valueAsString;
var sCity = this.getField("City").valueAsString;
var sEmail = this.getField("Email").valueAsString;
// Get a reference to the output field
var fOutput = this.getField("String");
var sOutput = "", aOutput = []; // Initialize output string and array
// Set the output array
if (sEvent) {
aOutput.push("Event: " + sEvent);
}
if (sCity) {
aOutput.push("City: " + sCity);
}
if (sEmail) {
aOutput.push("Email: " + sEmail);
}
// Join the elements of the array into a string, separated by a space
if (aOutput.length > 0) {
sOutput = aOutput.join(" ");
}
// Set the field value to the output string
fOutput.value = sOutput;
})();
If you want it to happen automatically, you could use the following custom calculation script for the "String" field
// Custom calculation script for String field
(function () {
// Get the field values, as strings
var sEvent = this.getField("Event").valueAsString;
var sCity = this.getField("City").valueAsString;
var sEmail = this.getField("Email").valueAsString;
var sOutput = "", aOutput = []; // Initialize output string and array
// Set the output array
if (sEvent) {
aOutput.push("Event: " + sEvent);
}
if (sCity) {
aOutput.push("City: " + sCity);
}
if (sEmail) {
aOutput.push("Email: " + sEmail);
}
// Join the elements of the array into a string, separated by a space
if (aOutput.length > 0) {
sOutput = aOutput.join(" ");
}
// Set this field's value to the output string
event.value = sOutput;
})();