Form Object
By: aathishankaran
One of the principal uses of JavaScript is providing a means to interact with the user on the client side. Most of the time, this interaction with the user happens through an HTML form. As a result, the JavaScript form object is an important object within the JavaScript object model. When you work with the form object, you do not do that much with a form object in and of itself. Rather, the form object provides a container by which you can retrieve data from the user. In HTML, the form object is defined as
SYNTAX
<FORM
[NAME="formName"] [ACTION=" serverURL"] [ENCTYPE=II
encodingType"]
[METHOD=GETI POST] [TARGET="windowName"] [onSubmit="methodName"]>
</FORM>
EXAMPLE:
<Html>
<Head>
<Title>
Form
Example
</Title>
<Body>
<FORM
NAME="form1"
ACTION=â€http://www.java-samples.com/cgi-bin/guest.plâ€
METHOD=POST
onSubmit="alert( 'Data Submited')">
<Input
Type=Text
Name=t1
Size=20
>
<Input
Type=Text
Name=t2
Size=20
>
<Br>
<Input
Type=Submit>
</FORM>
</Body>
</Html>
Output
Click on the Submit Query Button to send the data to the server.
As soon as the data is submitted the onSubmit() event of the form is fired.
To define a form, follow standard HTML conventions:
<FORM.NAME="form1"
ACTION=â€http://www.java-samples.com/js/script. jfm"
METHOD=GET>
<!-
Enter form objects here ->
</FORM>
Archived Comments
Most Viewed Articles (in JSP ) |
Latest Articles (in JSP) |
Comment on this tutorial