Solved

How do you break up long lines of JS code?

Posted on 2004-09-28
4
287 Views
Last Modified: 2010-04-17
If you have an extremely long line of JS code, e.g.,

document.forms[0].required.value=('CndnFBFirstName:FB Frst Name required,CndnFBLastName:FB Lst Name reqyuired,CndnFBRel:FB Relationship required');

(this is on one continous line, not broken up as above), how do you "break" it into several lines...tried just a simple Return to get to a new line but the program will then not run so this isn't the solution! Rats !As the site and its choices develop, this line is going to grow a bunch.

Thanks,
Ron
0
Comment
Question by:ronaldj
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
aratani earned 50 total points
ID: 12169585
Try putting an escape character \ after every line that you want to break i.e. something like below,

var stringVar = "I am a string that \
extends \
beyond a single line";

AJ
0
 

Author Comment

by:ronaldj
ID: 12169635
Once again, Mr. "A" to the rescue!

Thanks,
Ron
0
 
LVL 4

Expert Comment

by:aratani
ID: 12169692
Have I answered some other question of yours .. :)?

AJ
0
 

Author Comment

by:ronaldj
ID: 12169788
Yes. Yesterday in my dilema of executing multiple JS routines on an event trigger...remember we discovered that the second ";" in calling two routines from an event was unecessary...originally I had:

onClick="CcolorB3();SetReqFieldsBiii();"

and was corrected to be:

onClick="CcolorB3();SetReqFieldsBiii()"

which did the trick...as an aside, I landed up abandoning the 2 event trigger! (hey, at least I learned something)...opted instead for an onkeyup event for the 2nd to set required fields data set for a form...depending on the options of the form selected, required fields change...
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now