H I O X INDIA
Javascript Tutorial
Google
Web hscripts.com
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java-Script Tutorial
Introduction
Variables
Operators
Statements
Loops
Functions
Objects
Arrays
Browser Objects
Form DOM
Ask Your Doubts
Feedback





Javascript Form object


Topic

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



Explanation

Form Object :
        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";



        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.

privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Other Links