Page 312 - Web Applications (803) Class 11
P. 312

The confirm( ) Method
              This method is used to obtain confirmation from the user about an action. For example, if a user wants to delete
              something or cancel a purchase on an online website, a dialog box will display asking the user to acknowledge the
              deletion or order cancellation.

              Ð ÐConfirm method brings up a dialog box with a question mark icon, a question, and two buttons: OK and Cancel.
              Ð ÐIt gives the value of the clicked button.

              Ð ÐIt only needs one argument, which is the question to ask the user.
               ÐIf the user clicks the OK button, a true value is returned.
              Ð
              Ð ÐIf the user presses the Cancel button, the returned value is set to false.
              Example:
                 <HTML>
                 <HEAD>
                 <TITLE> Using confirm box </TITLE> </HEAD>
                 <BODY>
                 <script type="text/javascript">
                 var answer=confirm("Do you want to cancel your Aadhaar Application?");
                 if (answer == true) {
                 alert("Application has been canceled!");
                 }
                 else{
                 alert("Book appointment for biometic scan");
                 }
                 </script>
                 </body> </html>
              Output:

















              When you click on the “OK” button, with the message “this page says”. Then a new window opens:


















                310     Touchpad Web Applications-XI
   307   308   309   310   311   312   313   314   315   316   317