473,399 Members | 2,858 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,399 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 2938
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.