Copy link to clipboard
Copied
I know this is simple, but I've monkeyed with it all day.
Form has name fields: first name, middle name, last name, suffix.
I want a text box will will display this full name in other parts of the form - but without extra spaces if there is not a middle name.
Right now I've got this:
var s1 = getField("First Name").valueAsString; var s2 = getField("Last Name").valueAsString; var s3 = getField("Middle Name").valueAsString; var s4 = getField("Suffix").valueAsString; event.value = s1 + " " + s3 + " " + s2 + " " + s4;
Can anyone point me in the right direction? Any assistance is appecriated - thank you!
You can use this code:
var s1 = getField("First Name").valueAsString;
var s2 = getField("Last Name").valueAsString;
var s3 = getField("Middle Name").valueAsString;
var s4 = getField("Suffix").valueAsString;
var names = [];
if (s1!="") names.push(s1);
if (s2!="") names.push(s2);
if (s3!="") names.push(s3);
if (s4!="") names.push(s4);
event.value = names.join(" ");
Try this:
if (s3 == "")
event.value = s1 + " " + s2 + " " + s4;
else
event.value = s1 + " " + s3 + " " + s2 + " " + s4;
Copy link to clipboard
Copied
You can use this code:
var s1 = getField("First Name").valueAsString;
var s2 = getField("Last Name").valueAsString;
var s3 = getField("Middle Name").valueAsString;
var s4 = getField("Suffix").valueAsString;
var names = [];
if (s1!="") names.push(s1);
if (s2!="") names.push(s2);
if (s3!="") names.push(s3);
if (s4!="") names.push(s4);
event.value = names.join(" ");
Copy link to clipboard
Copied
This works - thank you so much for taking the time to reply. Thanks for sharing this!
Pete.
Copy link to clipboard
Copied
Try this:
if (s3 == "")
event.value = s1 + " " + s2 + " " + s4;
else
event.value = s1 + " " + s3 + " " + s2 + " " + s4;
Copy link to clipboard
Copied
Hi Bernd - thank you so much! This also works and I really appreciate you taking your time and expertise to answer me. Thanks again!
Pete.