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

    Question sent input of a prompt

    See this script (found it on this site)

    <script language="JavaScript">
    <!--
    var name=prompt("Enter Your Name, Please.","name");
    var today = new Date ()
    var hrs = today.getHours();
    document.writeln("<b><font size=4 face='Comic Sans MS'>");
    document.writeln("<b>");
    if (hrs <= 12)
    document.write("Good Morning "+name+'!');
    else if (hrs <= 18)
    document.write("Good Afternoon "+name+'!');
    else
    document.write("Good Evening "+name+'!'); document.writeln("<br>");
    // -->
    </script>

    How can i sent the input of the prompt as an input form? I want to use a prompt(1) as a question, followed by a prompt(2). Then i want to print the input of the prompts (document.write) and finaly sent the input by a post action. But how can i sent the inpyut of the prompts?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    ???

    <html>
    <head>
    <title>untitled</title>
    </head>
    <body>
    <form action="javascript:alert('Submitted.')" method="post">
    <input type="hidden" name="user_name" value="">
    </form>
    <script type="text/javascript" language="javascript">

    var name = prompt('Enter Your Name, Please.', 'name');
    if (name) {
    name = name.charAt(0).toUpperCase() + name.substring(1); //capitalize?
    var today = new Date();
    var hrs = today.getHours();
    document.write('<b><font size="5" face="Comic Sans MS">');
    if (hrs <= 12) document.write('Good Morning, ');
    else if (hrs <= 18) document.write('Good Afternoon, ');
    else document.write('Good Evening, ');
    document.write('<font color="darkred">' + name + '</font> !</font></b>');
    document.forms[0].user_name.value = name;
    setTimeout('document.forms[0].submit()',3000); //3 sec. delay
    }

    </script>
    </body>
    </html>

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just use a hidden field and change the value dynamically to the value of the prompt.

    Hope that helps!

    Happy coding!


  •  

    Posting Permissions

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