Expand my Community achievements bar.

How to use carriage return in formcalc

Avatar

Level 3

I'm sure the answer to this question is simple, but being new to formcalc (and scripting in general) I am having problems with it.

The details:

I have a dynamic form in livecycle. The two fields I am having problems with currently are a drop down list, and a text box (not field) associated with it. What is listed in the text box is dependant upon the choice from the dropdown list. So far everything is, functionally, working. I have the formcalc scripting event set to change on the dropdown list with the following script

if (xfa.event.newText == "Office 1") then

     OfficeAddress1 = "123 Street Road #xD Town City, US 12121 #xD (111) 555-1414"

endif

"Office 1" being the dropdown selection

OfficeAddress1 being the name of the text field

The fake address being the address, seperated by carriage return symbols (#xD) to indicate where I want it to jump to the next line.

The script is working fine except that the #xD symbols are showing up on the final form. How do I prevent this?

Thanks for you assistance.

3 Replies

Avatar

Former Community Member

In Javascript I use a \n to indicate a newline. It woudl be easy to change that script to javascript to use this.

Paul

Avatar

Level 6

For FormCalc, escaped characters are unicode constants.  Replace the #xd with \u000d if you want to continue to use FormCalc.

Avatar

Level 3

Thanks Paul, good advice.

For anyone that would want to do this in formcalc, the embarrassingly simple way of using a carriage return in the script is... hitting the enter button... no syntax required.

Don't bother trying to line it up in the scripting screen (my mistake), that only puts more spaces than is necessary and will mess up the text orientation on the final form. Just hit enter and don't worry if it's not lined up, it will be.