Friday, September 5, 2008

Confirm Boxes

Place the following code in the body of your HTML document. (Remove the alert box if you like. ):

<form>

<input type = ''button" value = "Click here to check the weather" onClick = "confirm(‘Its sunny today ' ) ; " >

</form>


We have created an input button inside a form. Input elements such as buttons must always be placed inside a form, between <form> and </form> tags.


Take a look in a browser window at the results of this code. The onClick event handler means that when you click on the button, a confirm box pops up. An event handler allows you to specify what code to execute when an event takes place. You can change the message on the button or in the confirm box by changing the appropriate text in the code. Be sure you’re also using all semicolons, quotation marks, and other punctuation correctly.

Syntax is very important in JavaS cript, unlike in HTML, where typos are often overlooked by browsers.

Now we’ll take a look at one more type of pop-up box, the message input box.

Message input boxes