Linefeed problem - please help

J

Jürgen Heyn

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();
}
 
B

Brian Genisio

Jürgen Heyn said:
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
 
M

Michael Winter

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
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
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>.
 
R

Randy Webb

Jürgen Heyn said:
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
 
J

Jürgen Heyn

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,789
Messages
2,569,634
Members
45,342
Latest member
Sicuro

Latest Threads

Top