473,287 Members | 1,565 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,287 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 2925
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?...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
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
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...

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.