Popups in javascript

There are three kinds of popup boxes in JavaScript
Who to define array in php?

  1. Alert box
  2. Alert box display message with ok button
    Example:

    <html>
    <script>
    alert(“Hello Viewers”);
    </script>
    </html>

  3. Confirm box
  4. Confirm box display message with ok and cancel button, it is use to take user confirmation. If we click ok, it returns TRUE and if we click cancel it returns FALSE.
    Example:

    <html>
    <script>
    var a = confirm(“Are you sure!”);
    if(a)
    {
    // true statement
    }
    else
    {
    // false statement
    }
    </script>
    </html>

  5. Prompt box
  6. Prompt box is use to take input from user. Prompt box returns the string value and if required we can convert string value to integer with help of parseInt() method.
    Example:

    <html>
    <script>
    var a = prompt(“Enter Name “);
    alert(“Hello “+a);
    var age = parseInt(prompt(“Enter Age “));
    alert(“You are “+ age +” years Old”);
    </script>
    </html>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.