IT Community - Software Programming, Web Development and Technical Support

How do I get the value of a form control?

This is a discussion on How do I get the value of a form control? within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all....... How do I get the value of a form control? Thanks & Regards itbarota....


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 09-13-2007, 02:52 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default How do I get the value of a form control?

Hi all.......

How do I get the value of a form control?

Thanks & Regards
itbarota.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-13-2007, 02:58 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: How do I get the value of a form control?

Hi all.....

In HTML documents, named forms may be referred to as named properties of the document.forms collection, and named form controls may be referred to as named properties of the form's elements collection:
var frm = document.forms["formname"];
var contrl = frm.elements["elementname"];

The (string) value property of such controls can be read directly from the element:-
var value = contrl.value;
var value = (+contrl.value); //string to number: see 4.21

Some exceptions would be:
First Exception: Where the control is a SELECT element, and support for older browsers, such as NN4, is required:

var value = contrl.options[contrl.selectedIndex].value;

Second Exception: Where several controls share the same name, such as radio buttons. These are made available as collections and require additional handling. For more information, see:-
Referencing Forms and Form Controls

Third Exception: File Inputs where most current browsers do not allow the reading of type="file" input elements in a way that is useful.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-26-2007, 03:13 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Smile Re: How do I get the value of a form control?

<html>
<head>
<title>Selecting Text Upon Focus</title>
</head>

<body>
<form name="form1" method="POST">
<h2>Selecting Text Upon Focus</h2>
<p>Username:<br>
<input type=text size=25 maxlength=256 name="Username" onFocus="this.select()"><br>
Browser used:<br>
<input type=text size=25 maxlength=256 name="Browser" onFocus="this.select()"><br>
Email address:
<strong> <br>
</strong>
<input type=text size=25 maxlength=256 name="EmailAddress"onFocus="this.select()">
</p>
<h2>
<input type=submit value="Register">
<input type=reset value="Clear">
</h2>
</form>
</body>
</html>
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date/time stamp a form field as the form is submitted itbarota HTML, CSS and Javascript Coding Techniques 1 02-06-2008 09:16 PM
Date/Time stamp a form field as the form is submitted itbarota HTML, CSS and Javascript Coding Techniques 2 01-17-2008 07:47 PM
How can I clear the form field values after the user has submitted the form for clien itbarota HTML, CSS and Javascript Coding Techniques 1 11-01-2007 10:39 PM
How can I pass a hidden value to a form and submit that form when a text link is clic itbarota HTML, CSS and Javascript Coding Techniques 1 10-17-2007 07:07 AM
use of Custom Control and User Control? a.deeban ASP and ASP.NET Programming 1 08-20-2007 07:25 AM


All times are GMT -7. The time now is 02:00 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0