Solved

How do you break up long lines of JS code?

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

809 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