Javascript Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback
 




DOM Form object


Tutorials Javascript

Topic

How to get a Form object in javascript?
Function or method to dynamically submit a form?



Explanation
        Form object is created for every html form element. We can dynamically submit, reset, handle other object like button, checkbox etc.. in the form using form object in javascript.

Methods or Functions:
The following are the list of DOM (Dynamic Object Model) function or methods that can be used to do dynamic changes in a form using javascript.
All the below examples use the following form element
<form name=tform action="index.php" method=post>
<input type=button value=xxx> </form>

DOM Method Description Example
submit() Used to dynamically submit a form using javascript To Submit:
document.tform.submit();
reset() Used to dynamically reset the values of the form To Blur:
document.tform.reset();
handleEvent() Used to invoke event handlers


The form object has the following properties.
All the below examples use the following form element
<form name=tform action="index.php" method=post>
<input type=button value=xxx> </form>

DOM Property Description Example
action Used to get or set the action attribute of form field. To Get:
var ss = document.tform.action;
To Set:
document.tform.action = "form-object.php";
elements property "elements" returns an array containing all the objects (like button, checkbox, etc..) in a form To Get:
var ss = document.tform.elements;
encoding Used to get or set the enctype attribute of form field. To Get:
var ss = document.tform.encoding;
To Set:
document.tform.encoding = "";
length Property "length" is used to check the number of elements present in the form. To Get:
var ss = document.tform.length;
method Property "method" is used get or set the attribute "method" of form field as POST or GET. To Get:
var ss = document.tform.method;
To Set:
document.tform.method= "GET";
name Property "name" is used to get or set the name of the form. To Get:
var ss = document.tform.name;
target Property "target" is used get or set the attribute "target" of the form. To Get:
var ss = document.tform.target;
To Set:
document.tform.target = "xxxx";





A Note
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

Other Links

web hosting