473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

FAQ Topic - How do I get the value of a form control?

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

Feb 19 '07 #1
3 2928
FAQ server wrote on 19 feb 2007 in comp.lang.javascript:
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:
I would not use the "form controls" but "form elements".

After all the DOM uses:

document.forms['..'].elements['..']

Do not let terrible MS asp.net terminology sip into this FAQ.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 19 '07 #2
On Feb 19, 9:55 am, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
FAQ server wrote on 19 feb 2007 in comp.lang.javascript:
>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:

I would not use the "form controls" but "form elements".

After all the DOM uses:

document.forms['..'].elements['..']

Do not let terrible MS asp.net terminology sip into this FAQ.
"Control" is terminology from the W3C HTML specification, referring to
TEXTAREA, INPUT, SELECT and BUTTON elements (and hypothetically OBJECT
elements). Previously it has been suggested that "element" may be
confusing because all HTML elements are represented in the DOM with
elements implementing the Element interface.

Richard.

Feb 19 '07 #3
Richard Cornford wrote on 19 feb 2007 in comp.lang.javascript:
On Feb 19, 9:55 am, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
>FAQ server wrote on 19 feb 2007 in comp.lang.javascript:
>>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:

I would not use the "form controls" but "form elements".

After all the DOM uses:

document.forms['..'].elements['..']

Do not let terrible MS asp.net terminology sip into this FAQ.

"Control" is terminology from the W3C HTML specification, referring to
TEXTAREA, INPUT, SELECT and BUTTON elements (and hypothetically OBJECT
elements). Previously it has been suggested that "element" may be
confusing because all HTML elements are represented in the DOM with
elements implementing the Element interface.
I would have objected if I had known.

Perhaps "input element"?

Throwing a switch perhaps,
but entering or dropping text does not satisfy
my understanding of controlling.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
109
by: MSG | last post by:
Michel Bardiaux <michel.bardiaux@peaktime.be> wrote in message news:<G4idnfgZ0ZfCWbrdRVn2jQ@giganews.com>... > Mark Shelor wrote: > > > > > OK, Sidney, I am considering it. I can certainly...
5
by: Nathan Sokalski | last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an...
13
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On...
25
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does parseInt('09') give an error? ----------------------------------------------------------------------- ...
2
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I get the value of a form control? -----------------------------------------------------------------------...
19
by: Dave | last post by:
If Iwant to check if dataset1.SelectQuery1.column1 == System.DBNull.Value. How do I do this? What I wrote above will give an error. -- L. A. Jones
2
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.