Accessing Form Element Values
The above code is correct (obviously!)
oText = oForm.elements["text_element_name"]; OR
oText = oForm.elements[index];
However, is this possible?
It seems to work in IE (shock, horror) but not in FF or Chrome.
$page = "text_element_name";
oText = oForm.elements[$page];
I think FF and Chrome are reading it as
which is NOT what I want.
$page = "text_element_name";
oText = oForm.elements["$page"]; // note the invert commas around $page
from Microsoft Webpage (f.e. http://msdn.microsoft.com/en-us/library/ms533050.aspx )
elements Collection Internet Development Index
only object FORM
Retrieves a collection, in source order, of all controls in a given form. input type=image objects are excluded from the collection.
[ oColl = ] FORM.elements
[ oObject = ] FORM.elements(vIndex [, iSubIndex])
oColl Array of button, input, select, and textArea objects.
oObject Reference to an individual item in the array of elements contained by the object.
vIndex Required. Integer or string that specifies the element or collection to retrieve. If this parameter is an integer, the method returns the element in the collection at the given position, where the first element has value 0, the second has 1, and so on. If this parameter is a string and there is more than one element with the name or id property equal to the string, the method returns a collection of matching elements.
iSubIndex Optional. Position of an element to retrieve. This parameter is used when vIndex is a string. The method uses the string to construct a collection of all elements that have a name or id property equal to the string, and then retrieves from this collection the element at the position specified by iSubIndex.
The following table lists the members exposed by the elements object. Click a tab on the left to choose the type of member you want to view.
length Sets or retrieves the number of objects in a collection.
item Retrieves an object from the all collection or various other collections.
namedItem Retrieves an object or a collection from the specified collection.
tags Retrieves a collection of objects that have the specified HTML tag name.
urns Retrieves a collection of all objects to which a specified behavior is attached.
This collection can contain any combination of the button, input, select, and textArea objects. For compatibility with existing Web content, however, input type=image objects are excluded.
A complete list of form controls is provided in the Introduction to Forms.
This collection is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
sorry mate. thanks for the reply but i'm not with you. perhaps i not as clever as you!
I just need that statement in my first post to work in FF. Do you know how?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread