Name
HTMLFormControlsCollection — a array-like object of form controls
Inherits from
HTMLCollection
Synopsis
HTMLFormControlsCollection is a specialized HTMLCollection
used by Form elements to represent collections of form controls.
Like HTMLCollection, you can index it numerically, like an array, or
treat it like an object and index it with the names or IDs of form
controls. HTML forms often have multiple controls (usually radio
buttons or checkboxes) that have the same value for their name
attribute, and an
HTMLFormControlsCollection handles this differently than an ordinary
HTMLCollection would.
When you read a property of an HTMLFormControlsCollection, and
the form contains more than one element that has that property as
its name, the HTMLFormControlsCollection returns an array-like
object of all form controls that share the name. In addition, the
returned array-like object has a value
property that returns the value
attribute of the first checked radio
button with that name. You can even set this value
property to check the radio button
with the corresponding value.
Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.