These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Problem with Javascript using conditional and xfa.messageBox

buckynwd
Registered: Jan 6 2011
Posts: 11
Answered

I'm completely new and self-taught to java script. Today I wrote this and cannot figure out where my syntax error is. Could somebody please elighten me?
 
SF182.#subform[0].SecC.Total.1c::enter - (JavaScript, client)

if (OEDCode = "3504 HQ General Council Supervisory Attorney" && SecC.Total.1c > 1500)
{
xfa.host.messageBox("The amount you entered exceeds the permitted amount."\n\n"Please call OED at 202-273-3918.", "Max Total Exceeded", 1, 0);
}

 
Thanks in advance!

My Product Information:
LiveCycle Designer, Windows
DaveyB
Registered: Dec 10 2010
Posts: 70
Accepted Answer
Ooops! Fix the quotes around the '\n\n' and it should work! ;)

"The amount you entered exceeds the permitted amount.'\n\n' Please call OED at 202-273-3918."

Single quotes only, otherwise it terminates the string! :)

To explain that, look at this:

"My name is Johnathan but "John" is what my friends call me"

A function call reads this, and sees the parameter "My name is Johnathan but " followed by extraneous characters where it expects a comma (,) to separate the parameters. The whole function fails as text strings are expected to be in double quotes ("). The solution is to use single quotes for the inner quotation:

"My name is Johnathan but 'John' is what my friends call me"

The function call now sees a string which begins and terminates with a double quote (") while the parser can handle the single quotes (') and their contents accordingly.

Hope that helps!

LiveCycle Designer 8.0
"Genius is one percent inspiration, ninety-nine percent perspiration." ~~ Thomas Edison
"If at first you don't succeed, get a bigger hammer." ~~ Alan Lewis
"If the conventional doesn't work, try the unconventional" ~~ DaveyB

buckynwd
Registered: Jan 6 2011
Posts: 11
Thanks DaveyB stupid mistake on my part and a great explanation on your part!