Table of Contents
Dialog box is a kind of pop up that asks users to make decisions or get information. The primary purpose of the dialog windows is used to interact with users.
- Dialog box alert().
- Dialog confirm().
- Dialog input prompt().
These three dialog have different functions and objectives.
Dialog Box Alert()
The syntax of writing and using alerts is quite easy, and you can use it in the following ways
The alert() function will not return any value when executed.
Var text = " Hello Sigit";
A brief description:
- Alert dialog force the browser and user to read the message displayed.
- Alert() support with all browsers
Confirm Dialog Window ()
The confirm() dialog windows used so that the user confirms before the system takes certain actions.
The value generated from the Confirm Box is true or false, if the user clicks the “OK” button, it will return true, and if the user clicks the “Cancel” button, it returns false. For more details, please see the following code example:
when we delete/make changes data, we recommend you display confirm box dialog to confirm.
confirm("Delete user sigit?");
The dialog box confirm() will return true when we select the OK button and will return false when we select Cancel.
The return value can be accommodated in the variable for the next process.
var result = confirm("Delete user sigit ?")
alert("Successfull delete user")
alert(“thanks not to delete that user”)
Prompt Dialog Window()
The window prompt() serves to retrieve input from the user. The dialog window prompt() return a string value from what the user entered.
var email = prompt("Your email address ?")
- Dialog alert() applied to display information or warnings.
- Windows confirm() applied to confirm before making further steps.
- Dialog input prompt() used if you need a value or answer from the user.
- The three dialog windows above will found in making applications that require interaction with users.