Sunday, 11 August 2013

Popup boxes

Popup boxes:
1.       Alert box: this box is used to display a message to the user.
It ensures that the user reads the message and click on “OK” button because it will not allow the user to perform any operation without checking “OK” button.
Syntax: alert(“message”);

2.       Prompt box:
This box is used to provide information by the user.
The prompt box contains two buttons (1) OK (2) CANCEL
·         If the user click on “OK” button then it will read the information typed by the user from the user box.
·         If the user clicks on “CANCEL” button then it will read NULL value.

2nd Syntax: prompt(message, default-value);
<html>
 <head>
  <script type="text/javascript">
   var name=prompt("enter your name");
   document.write("name:"+name);
  </script>
 </head>
</html>

output:

enter any name in that popup box
and click on "ok" button



No comments:

Post a Comment