Solved

How do you break up long lines of JS code?

Posted on 2004-09-28
4
294 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

840 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