Page 354 - Webapplication11_C11_Flipbook
P. 354
{
alert("You can get a learner's licence only");
}
else
{
alert("You can get a driver's licence");
}
</SCRIPT>
</BODY>
</HTML>
Output of the above code is as follows:
When you click on the “OK” button, with the message “this page says”. Then a new window opens with the message
“You can get a driver’s licence”.
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>
352 Touchpad Web Applications-XI

