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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Returning Variables in Alerts

    I'm making something that asks for your name (prompt) and then says 'Hey so-and-so' via alert.

    var x = prompt("What's your name/nickname?")
    alert("Hey document.write(x)!")

    It doesn't carry out the command. It says it how it is. How do I get it to say the variable in the alert?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    New York, USA
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    var x = prompt("What's your name/nickname?", "");
    alert("Hey "+x+"!");


  •  

    Posting Permissions

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