Form Control Arrays

This demo illustrates how to access form control arrays and form controls with PHP array names. It is in response to renatofmiguel's question at SPF.

Form 1, with one set of controls

If there is only one control with name='existente' then elements['existente'] is a Node (an INPUT element).

Form 2, with multiple sets of controls

If there is more than one control with name='existente' then elements['existente'] is a Node-List (an array).

In both of the above we also have form controls with PHP array names, for example: name='quantidade[0]', name='quantidade[1]', etc. These do not create form control arrays because their names are all different. They are accessed like this: elements['quantidade[0]'].value, elements['quantidade[1]'].value, etc.