Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do you break up long lines of JS code?

Posted on 2004-09-28
4
Medium Priority
?
301 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 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Starting up a Project
Screencast - Getting to Know the Pipeline

916 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