Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Javascript:Prompt Dialog Box

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 217
    Comment on it

    Prompt dialog Box is used to have an input from the users or to get confirmation on any input.

    This dialog box is displayed using a method called prompt() which takes two parameters:-

    (i) A label which you want to display in the text box.

    (ii) A default string to display in the text box.

    It is mostly used when you want to pop-up a text box for users input.

    It enables you to interact with the users and the user only need to fill in the fields and then click OK.

    It displays a dialog box with two buttons:

    Cancel and OK.

    If the user clicks on the Cancel button, the window method prompt() returns null.

    Similarly when the user clicks on the OK button, the window method prompt() will return the entered value from the text box.

    Have a look on this simple example to understand the concept of prompt dialog box:-

    <body>
    <p>Click on the button below to see how prompt dialog box works </p>
    <form>
    <input type="button" value="Click Me" onclick="getConfirmation();" />
    </form>
    <script type="text/javascript">
     function getValue(){
                   var retVal = prompt("Enter your name : ", "your name here");
                   document.write("You have entered : " + retVal);
                }
    </script>
    </body>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: