Javascript Dialog Box Functions

The prompt, alert and confirm functions.

Javascript provides three dialog box methods for communicating with the application user. The prompt() creates a dialog box for the user to enter information.
The confirm() function dialog box has an OK and a Cancel button. Clicking on the ok button returns true. Clicking on the cancel button returns false.
The alert() function displays a message and an ok button but returns nothing.

Simple demonstration of prompt,alert and confirm.
The javascript code used by this demo is listed below

function communicate() {
//Demonstrate alert,confirm and prompt functions.
var ask = confirm("Continue?");// returns true or false
alert(ask) ;//Show value of button selected.
// variable = prompt(Message or request,default value or empty quotes for input)
var name = prompt("Please enter your name",""); // If cancel is clicked then null will be returned.
if(name == "")
alert("Hello No name provided") ;
alert("Hello " + name);
}//end of function communicate()

Site Index