By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,461 Members | 1,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,461 IT Pros & Developers. It's quick & easy.

Linefeed problem - please help

P: n/a
Good afternoon,
I would like to join several elements in one string. Every element should
have its own line.
After this I would like to display the string on a document.
The following code inserts a space between the elements but the are all in
one line.
Where is my mistake ?
Thank you for any hint.
Best regards
Jürgen Heyn, Wilhelmshaven, Germany

function CreateMailText()
{
var MailText = ""
var obj = self.Inhalt.document;
MailText += "Lieferanschrift\n";
MailText += obj.forms[0].Firma1.value+"\n";
MailText += obj.forms[0].Anrede1.value+"\n";
MailText += obj.forms[0].Vorname1.value+"\n";
MailText += obj.forms[0].Nachname1.value+"\n";

obj.clear();
obj.open();
obj.write('<html>');
obj.write('<head>');
obj.write('</head>');
obj.write('<body bgproperties="fixed"
background="Bilder/Hintergrund.gif">');
obj.write('</head>');
obj.write(MailText);
obj.write('</body>');
obj.write('</html>');
obj.close();
}
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jürgen Heyn wrote:
Good afternoon,
I would like to join several elements in one string. Every element should
have its own line.
After this I would like to display the string on a document.
The following code inserts a space between the elements but the are all in
one line.
Where is my mistake ?
Thank you for any hint.
Best regards
Jürgen Heyn, Wilhelmshaven, Germany

function CreateMailText()
{
var MailText = ""
var obj = self.Inhalt.document;
MailText += "Lieferanschrift\n";
MailText += obj.forms[0].Firma1.value+"\n";
MailText += obj.forms[0].Anrede1.value+"\n";
MailText += obj.forms[0].Vorname1.value+"\n";
MailText += obj.forms[0].Nachname1.value+"\n";

obj.clear();
obj.open();
obj.write('<html>');
obj.write('<head>');
obj.write('</head>');
obj.write('<body bgproperties="fixed"
background="Bilder/Hintergrund.gif">');
obj.write('</head>');
obj.write(MailText);
obj.write('</body>');
obj.write('</html>');
obj.close();
}


What browser are you using? I have never run into this, but my
intuition would say that you might need to do a carriage return/line
feed, instead of a simple line feed. IOW, "\r\n" instead of "\n".

Unless of course, you are talking about the way that the actual browser
looks. In that case, this is an HTML issue... use <BR>

:)
Brian

Jul 20 '05 #2

P: n/a
On Fri, 20 Feb 2004 15:03:43 +0100, Jürgen Heyn <j.****@gmx.de> wrote:
I would like to join several elements in one string. Every element should
have its own line.
After this I would like to display the string on a document.
The following code inserts a space between the elements but the are all
in one line.
Where is my mistake ?


[snip]

You can use document.writeln() in place of document.write(). The former
automatically adds a new line after the text has been written, whereas the
latter does not (as you have discovered).

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3

P: n/a
Jürgen Heyn wrote:
Good afternoon,
I would like to join several elements in one string. Every element should
have its own line.
After this I would like to display the string on a document.
The following code inserts a space between the elements but the are all in
one line.
Where is my mistake ?
Thank you for any hint.
Best regards
Jürgen Heyn, Wilhelmshaven, Germany

function CreateMailText()
{
var MailText = ""
var obj = self.Inhalt.document;
MailText += "Lieferanschrift\n";
MailText += obj.forms[0].Firma1.value+"\n";
MailText += obj.forms[0].Anrede1.value+"\n";
MailText += obj.forms[0].Vorname1.value+"\n";
MailText += obj.forms[0].Nachname1.value+"\n";


MailText += obj.forms[0].Nachname1.value + "\n<br />";

The \n will put a new line in the source code, but the br tag is
required to put a new line in the display.

Do it for each and every line above
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #4

P: n/a
JRS: In article <c1*************@ID-94872.news.uni-berlin.de>, seen in
news:comp.lang.javascript, Jürgen Heyn <j.****@gmx.de> posted at Fri, 20
Feb 2004 15:03:43 :-
I would like to join several elements in one string. Every element should
have its own line.
After this I would like to display the string on a document.
The following code inserts a space between the elements but the are all in
one line.
Where is my mistake ?


Since you are apparently writing to a page, ISTM likely that you need
<br> instead of \n; or that you should enclose that part in <pre> ...
</pre>.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links;
some Astro stuff via astro.htm, gravity0.htm; quotes.htm; pascal.htm; &c, &c.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 20 '05 #5

P: n/a
Good afternoon,

thank you very much for your help.
I now got the difference between "\n" and the <br> tag.
To generate a *.html page I use the <br> tag.
Joining the the textlines to be displayed as a .value property of a textarea
I the "\n".
Again thank you very much.
Everybody have a nice weekend.
Best regards
Juergen Heyn, Wilhelmshaven, Germany
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.