?
Solved

How do you break up long lines of JS code?

Posted on 2004-09-28
4
Medium Priority
?
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Six Sigma Control Plans
Progress

719 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