469,949 Members | 2,190 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,949 developers. It's quick & easy.

Linefeed problem - please help

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
5 2902
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
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
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
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
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.

Similar topics

4 posts views Thread by Johannes Busse | last post: by
2 posts views Thread by Jürgen Heyn | last post: by
3 posts views Thread by Wade G. Pemberton | last post: by
8 posts views Thread by Able | last post: by
1 post views Thread by sck10 | last post: by
1 post views Thread by Tor Inge Rislaa | last post: by
10 posts views Thread by Bob Quintal | last post: by
2 posts views Thread by Mark B | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.