Linefeed problem - please help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jürgen Heyn

    #1

    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.doc ument;
    MailText += "Lieferanschrif t\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.valu e+"\n";

    obj.clear();
    obj.open();
    obj.write('<htm l>');
    obj.write('<hea d>');
    obj.write('</head>');
    obj.write('<bod y bgproperties="f ixed"
    background="Bil der/Hintergrund.gif ">');
    obj.write('</head>');
    obj.write(MailT ext);
    obj.write('</body>');
    obj.write('</html>');
    obj.close();
    }


  • Brian Genisio

    #2
    Re: Linefeed problem - please help

    Jürgen Heyn wrote:
    [color=blue]
    > 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.doc ument;
    > MailText += "Lieferanschrif t\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.valu e+"\n";
    >
    > obj.clear();
    > obj.open();
    > obj.write('<htm l>');
    > obj.write('<hea d>');
    > obj.write('</head>');
    > obj.write('<bod y bgproperties="f ixed"
    > background="Bil der/Hintergrund.gif ">');
    > obj.write('</head>');
    > obj.write(MailT ext);
    > obj.write('</body>');
    > obj.write('</html>');
    > obj.close();
    > }
    >
    >[/color]

    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

    Comment

    • Michael Winter

      #3
      Re: Linefeed problem - please help

      On Fri, 20 Feb 2004 15:03:43 +0100, Jürgen Heyn <j.heyn@gmx.d e> wrote:
      [color=blue]
      > 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 ?[/color]

      [snip]

      You can use document.writel n() 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.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

      Comment

      • Randy Webb

        #4
        Re: Linefeed problem - please help

        Jürgen Heyn wrote:
        [color=blue]
        > 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.doc ument;
        > MailText += "Lieferanschrif t\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.valu e+"\n";[/color]

        MailText += obj.forms[0].Nachname1.valu e + "\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.javas cript FAQ - http://jibbering.com/faq/

        Comment

        • Dr John Stockton

          #5
          Re: Linefeed problem - please help

          JRS: In article <c153tv$1d7a96$ 1@ID-94872.news.uni-berlin.de>, seen in
          news:comp.lang. javascript, Jürgen Heyn <j.heyn@gmx.d e> posted at Fri, 20
          Feb 2004 15:03:43 :-
          [color=blue]
          >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 ?[/color]

          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.demo n.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.

          Comment

          • Jürgen Heyn

            #6
            Re: Linefeed problem - Thanky You !

            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


            Comment

            Working...