From: FAQ server on
-----------------------------------------------------------------------
FAQ Topic - How do I get the value of a form control?
-----------------------------------------------------------------------

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:-

http://www.jibbering.com/faq/faq_notes/form_access.html

Third Exception: File Inputs where most current browsers do not
allow the reading of type="file" input elements in a way that is useful.


--
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers. The sendings of these
daily posts are proficiently hosted by http://www.pair.com.

From: robinsridhar on
On Jun 27, 4:00 am, "FAQ server" <javascr...(a)dotinternet.be> wrote:
> -----------------------------------------------------------------------
> FAQ Topic - How do I get the value of a form control?
> -----------------------------------------------------------------------
>
> 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:-
>
> http://www.jibbering.com/faq/faq_notes/form_access.html
>
> Third Exception: File Inputs where most current browsers do not
> allow the reading of type="file" input elements in a way that is useful.
>
> --
> Postings such as this are automatically sent once a day. Their
> goal is to answer repeated questions, and to offer the content to
> the community for continuous evaluation/improvement. The complete
> comp.lang.javascript FAQ is athttp://jibbering.com/faq/index.html.
> The FAQ workers are a group of volunteers. The sendings of these
> daily posts are proficiently hosted byhttp://www.pair.com.

I have a similar kind of problem. can any body help me out.

I want to get objects element's value from a webpage where object name
or id is not given. I do not know how to get objects element's value
from a webpage without using id or name.

waiting for your reply.

Regards
Robin Shridhar
Banglalore, India
robinshridhar(a)gmail.com