Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Writing on separate lines

    How can the output of the following code be written on separate lines ??
    Code:
    <script type = "text/javascript">
      var x = 'Hello and Welcome'
    
      document.write(x.length)
      document.write(y.toUpperCase())
    
    </script>

  • #2
    New Coder
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Change this:

    Code:
    document.write(x.length)
    for this:
    Code:
    document.write(x.length + '<br />')

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,121
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Ummm...you mean lines in a browser?? Heard of HTML?

    document.write( x.length + "<br/>" + y.toUpperCase() + "<br/>");

    If you are trying to create a text file, instead of HTML:

    document.write( x.length + "\n" + y.toUpperCase() + "\n");

  • #4
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many many thanks everyone!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •