Saturday, 23 April 2016

Dialog Boxes in JavaScript

Alert Dialog Box: An alert dialog box is mostly used to give a warning message to the users.Mostly they gives only an "Ok button".

Confirmation Dialog Box: A confirmation dialog box is mostly used to take user's consent on any option. It displays a dialog box with two buttons mostly "ok" and "cancel"

Prompt Dialog Box: The prompt dialog box is very useful when you want to pop-up a text box to get user input. Thus, it enables you to interact with the user. The user needs to fill in the field and then click OK. If the user clicks the Cancel button, the window method prompt() returns null.

 

<html>
<head>

</head>
<body>

Show an Alert Dialog Box


Show a Confirmation Dialog Box


Prompt Dialog Box

</body> </html>
functions.js:
 
function showalert1(){
alert("Iam an alert")
}
function showalert2(){
confirm("Iam an alert")
}
function getValue()
{
var retVal = prompt("Enter your name : ", "your name here");
               document.write("You have entered : " + retVal);
}




No comments:

Post a Comment