View Full Version : element references & forms?

02-07-2004, 04:08 PM
Should document.form.name.element.name apply only to the form.elements collection?

For example, which reference should be used for an <object> in a form:

document.form.name.object.name -or- document.getElementById(object.id)

or does it matter?

02-07-2004, 05:04 PM
document.forms[formname].elements[elementnameorid] should work for all form controls, including object elements whose declare attribute is not set. I'm not sure you can rely on browsers when it comes to this, however, so it's safer to use document.getElementById(objectid)

02-07-2004, 05:07 PM
Sounds good; thanks for the information.