473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to write Multiple Lines in JS?

Wow
Do I have to replace all new lines with \n and document.write one line? Is
there something like perl's print lines

print << 'body';

body

in javascripts?
Jul 23 '05 #1
2 14660
Wow wrote:
Do I have to replace all new lines with \n and document.write one line? Is
there something like perl's print lines

print << 'body';

body

in javascripts?


No, JavaScript has no concept like the here document in Perl. The best you can
do is use something like the following if you have lots of stuff to
document.write():

document.write(
'stuff' +
' more stuff' +
' even more stuff' +
);

Since including \n in the output of a document.write() into the <body> of an
HTML document simply results in a space in the output, you might as well use
spaces and save yourself some typing. Another way to do this would be:

var output = [
'stuff',
'more stuff',
'even more stuff'
];
document.write(output.join('\n'));

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #2
In article <HPZMc.1221913$Ar.1037509
@twister01.bloor.is.net.cable.rogers.com>, a@alexa.com enlightened us with...
Do I have to replace all new lines with \n and document.write one line? Is
there something like perl's print lines

print << 'body';


IF I understand your question correctly...

var myString;
myString = "This is a line of text " +
"that I want over multiple lines. " +
"That way, I don't have to make one big line of "+
"unreadable text.";

document.write(myString);

The string will be all on one line in the browser.

As to a construct like the HERE doc in Perl, no, no such animal in JS AFAIK.

--
--
~kaeli~
When you choke a smurf, what color does it turn?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris S. | last post by:
I'd like to dynamically execute multiple lines of indented code from within a script, but I can't seem to find a suitable function. Exec only works with unindented code, and execfile only works...
14
by: JStrauss | last post by:
Hello, Can anybody give me some tips on the best and/or easiest way to display multiple lines in a field. The data is collected from a "textarea" field when the form is submitted, and I want to...
2
by: George | last post by:
Dear colleagues, I refer to your help with specific graphic problem. It is necessary to create a viewfinder in graphic application. It seems that the algorithm is simple: just draw lines in...
1
by: Loading name... | last post by:
hey asp.net 2.0 In my db (sql server 2005) I have a record which consist of multiple lines: "HEY THIS IS A TEST OF MULTIPLE LINES"
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
2
by: PengYu.UT | last post by:
Hi, In python, triple quote (""") can be used to quote a paragraph (multiple lines). I'm wondering if there is any equivalent in C++. For the following code, I could write the long string in a...
3
by: Bodyloss | last post by:
Hey all Ive ran into a bit of a problem when trying to parse multiple lines of javascript whitch are returned from an ajax request. On the main page where the request orginates, i have a <div...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.