#150 ✓resolved
nickg

Support for Form Named Elements, Form.item, Form.namedItem, Form.elements

Reported by nickg | April 8th, 2010 @ 03:21 PM

The current HtmlFormElement.elements isn't quite right, and Form is missing .item(), .namedItem(). The fun one is direct named elements, ala...

<form name="foo">
<input name="bar" />
</form>

so...
var aform = document.foo; // this is works already

aform.bar // is the number element, OR...
document.foo.bar // is the input element

This is going to be a bugger, with lots of unit tests. But it's one of the last biggies for core functionality in env.js.

--nickg

The spec http://dev.w3.org/html5/spec/Overview.html#dom-form-nameditem sayz:

Form . elements
Returns an HTMLCollection of the form controls in the form (excluding image buttons for historical reasons).

form . length
Returns the number of form controls in the form (excluding image buttons for historical reasons).

element = form . item(index)
form[index]
form(index)
Returns the indexth element in the form (excluding image buttons for historical reasons).

element = form . namedItem(name)
form[name]
form(name)
Returns the form control in the form with the given ID or name (excluding image buttons for historical reasons).

Once an element has been referenced using a particular name, that name will continue being available as a way to reference that element in this method, even if the element's actual ID or name changes, for as long as the element remains in the Document.

If there are multiple matching items, then a NodeList object containing all those elements is returned.

Returns null if no element with that ID or name could be found.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

a javascript browser environment

People watching this ticket

Pages