Using the Confirm Box
The confirm box is an advance form of alert box. It is used to display message as well as return a value (true or false). The confirm box displays a dialog box with two buttons, OK and Cancel. When the user clicks on OK button it returns true and when user clicks on Cancel button it returns false. The confirm box enables you to interrupt the JavaScript processing to ask the user a question and then continue processing based on which button is clicked.
Demo:
- Create a document named confirmBox.html.
- Write to following code:
- Execute the script by Opening the file in the Web Browser. If you are using Internet Explore click on “Allow Blocked Content” to allow the script to execute and you are using Mozilla Firefox then click on allow “ActiveX Controls”.
When you select OK:
When you select Cancel:
Thanks for reading this blog.