[thelist] getting type of form element

James Aylard evolt at pixelwright.com
Mon Nov 4 11:46:01 CST 2002


.jeff,

> document.forms[0].elements[0].type
>
> you'll get the following responses:  hidden, text, password, select-one,
> select-multiple, radio, checkbox, submit, button, image, textarea.

    Also, file is a possible value, if your form includes that field type.
    And curiously, both IE and Mozilla include the fieldset element in the
elements array, but indicate it as type "undefined". Further, if you happen
to provide name and value attributes for fieldset (although these are not
permitted per the W3C HTML 4.x recommendation), IE will return the value of
these attributes (although these may be considered "expando" properties, in
point of fact). Mozilla returns "undefined" for these as well.
    The inclusion of fieldset in the elements array/collection could be an
issue depending on how you are looping through it and what you're doing with
the values you get.

James Aylard




More information about the thelist mailing list