Sunday, 5 June 2011

Form Tag In JavaScript



Form:  By using this tag we can hold the html elements. To submit the page values we are using form tag.
Action : By using this attribute we can specify the page name to which you want to submit the form values.
<form method="get" action="file:///C|/Users/ADMIN/Desktop/page1.html">
<input type="text" name="txtuname">
<br>
<input type="text" name="txt2">
<br>
<input type="submit" value="Login" name="sub">
</form>
In the above script I have used the get method. If you use get method we can see the page values in the url. If we use we can’t see the page values in the url.
Difference between get method and post method.
Get method transfers the information through the URL address.
Post method transfers the information through the document body.
Get method is unsecured.
Post method is secured.
Get method can transfer limited amount of data.
Post method can transfer huge amount of data.
Get method can transfer only text data. Cannot transfer the files.
Post can transfer files also.
Get is very fast.
Comparing with the get post is little bit slow.

Form Elements: This property is used to read the elements of a form and returns an array. Each element refers one control of form.
Sample Script :
<script>
function fun1()
arr=frm1.elements
for(i=0;i<arr.lenght;i++)
alert(arr[i].name)
}
</script>
<form method="post" action="file:///C|/Users/ADMIN/Desktop/page1.html" id="frm1">
<input type="text" name="txtuname" id="txtUname">
<br>
<input type="text" name="txt2">
<br>
<input type="button" value="Login" name="sub" onclick="fun1()">


0 comments:

Post a Comment