HOWTO: Concatenate Fields

In JavaScript, the method for combining two fields together uses the plus sign “+” to act as the glue. Here is an example;

var my_variable = "Dear " + field.Salutation + " " + field.LastName

Result:

Dear Mr. Jones


Developer Tip:

Notice that in JavaScript you can use either single quotes or double quotes. This allows for added functionality. Just make sure and match your opening quote with the same closing quote. For example;

var my_variable = 'Dear ’ + field.Salutation + ’ ’ + field.LastName

Is the same as the above.

If you want to add a carriage return to your output then you need to use an escaped character. The letter “n” stands for “new line” and you would use “\n” to add the return. For example;

var my_variable = 'Dear ’ + field.Salutation + ’ ’ + field.LastName + '\nof ’ + field.Address

Result:

Dear Mr. Jones
of 555 Waverly Rd.