1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

document.write and multi line

Discussion in 'JavaScript' started by mahmood, Jan 2, 2006.

  1. #1
    I wonder if there is an easier way to print a multiline on the screen. At the moment I have to add a "document.write" to every single line. is there an easier way?
     
    mahmood, Jan 2, 2006 IP
  2. cytech

    cytech Guest

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Give this a try

    
    var multiLine="THE LINE
    
    GOES MULTI";
    
    document.write(multiLine);
    Code (markup):
     
    cytech, Jan 5, 2006 IP
  3. kniveswood

    kniveswood Well-Known Member

    Messages:
    764
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    120
    #3
    I dont see how you managed to write to multiple line by multiple document.write. You are writing to html right? In any case, try these:

    document.write("Line 1<br>Line2<br>Line3");
    Code (markup):
    document.write("Line 1\nLine2\nLine3");
    Code (markup):
     
    kniveswood, Jan 5, 2006 IP
  4. legend2

    legend2 Well-Known Member

    Messages:
    1,537
    Likes Received:
    74
    Best Answers:
    0
    Trophy Points:
    115
    #4
    just use \n, this returns a new line, then write the whole thing in one shot.
    good luck.

    keep in mind too than writeln exists too which adds a new line at the end.
     
    legend2, Jan 6, 2006 IP