Unit III: Adding Styles and Interactivity Using CSS and Javascript JavaScript Popup Boxes: Alert, Confirm, and Prompt Box
Review Write the basic JavaScript Syntax What is the function of the <script> tag? What is the use of the semi-colon? Is Javascript can be written in toggle case? Why? What is the standard JavaScript command for displaying text? Which sections of the html we can write/appear the JavaScript codes?
ALERT BOX An alert box is often used to “alert” the user for some information message. It contains a single statement and an OK button. When an alert box pops up, the user needs to click the OK button to proceed. (Note: the browser settings is Filipino)
Syntax of an Alert Box <html> <body> <script type= “text/ javascript ”> a lert(“Oops! You pressed the wrong key! Try Again!”); </script> </body> </html>
Confirm Box The confirm box is often used if you want the user to “confirm” or accept something. It contains question and the OK and the CANCEL buttons. When a confirm box pops up, the user needs to click either OK or CANCEL button to proceed. (Note: the browser settings is Filipino)
Syntax of an Confirm Box <html> <body> <script> confirm(“Are you sure all the information you entered are correct”); </script> </body> </html>
Prompt box A prompt box can be used to allow the user to input data before entering a page. It contains a question, an empty box called “ textfield ”, and OK and Cancel button. When prompt box pops up, the user needs to click either the OK or the Cancel button to proceed after inputting the data.
Syntax of a prompt box <html> <body> <script> prompt(“Please enter your name”); </script> </body> </html>
COMPUQUIZ/ EXERCISES 1. Write the JavaScript code to display the following:
Write the correct answer 4. Used to allow user to input data. 5. Used to allow user to accept something.
Assignment/Agreement Start working your web page for your final requirement to pass the subject.