HTML and CSS Reference
In-Depth Information
EXPLANATION ( CONTINUED )
3
The input type is a simple graphical button containing the text “Click me!”
4
When the user clicks the button, the onClick event handler is triggered and the
function called greetme() is called. It will send an alert dialog box to the screen, as
shown in Figure 11.22.
Figure 11.22 Using a button to call a function.
11.4.6 The submit() and reset() Methods
In addition to event handlers (fully discussed in Chapter 13), JavaScript provides two
methods for the forms object, the submit() and the reset() methods. These methods emu-
late the event handlers of the same name: The submit() method submits the form just as
though the user had clicked the submit button, and the reset() method resets the form
elements to their defaults just as if the user had clicked the reset button. Neither of these
methods trigger the onSubmit or onReset event handlers. (Note that the methods must
be spelled with lowercase letters.) These methods allow you to ask for user confirma-
tion, check input data, and so on, before sending the form to the server for processing.
EXAMPLE 11.15
<html>
<head><title>An HTML Form</title></head>
<body>
<b>
1
<form name=myForm
action="http://localhost/cgi-bin/environ.pl"
method="post">
<p>
<fieldset><legend><big> All About You</legend>
<p><font size=3 color="blue">
Type your name here:
2
<input type="text"
name="namestring"
size="50" />
 
 
Search WWH ::




Custom Search