Results 1 to 4 of 4

Thread: Writing to document?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    2

    Writing to document?

    How do i write to the document? I am new to the WEB?

  2. #2
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Simple really, use document.write()
    Alcohol & calculus don't mix.
    Never drink & derive.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    2
    Could you pleas provide an example? I am new and i am just trying to make a hello world program.

  4. #4
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    I am assuming you have had no javascript experience. Look at this HTML:

    Code:
    <html>
    <head>
    <title>document.write example</title>
    <script>
    var name = prompt("What is your name?", "Bob");
    document.write("Hello, " + name + "!");
    </script>
    </head>
    <body>
    </body>
    </html>
    var name = prompt("What is your name?", "Bob");
    This makes a variable called 'name' and asks the user what they want it to be. The default is Bob.
    document.write("Hello, " + name + "!");
    What this does is prints "Hello, " to the window and adds the variable 'name' after it, then adds "!". So, if you gave James as your name, the output would be "Hello, James!".
    Last edited by Wynd; May 18th, 2001 at 04:47 PM.
    Alcohol & calculus don't mix.
    Never drink & derive.

Posting Permissions

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



Click Here to Expand Forum to Full Width