This a valid call:
document.myform .elements['myelement']
so is this:
document.forms[0].elements[1]
but not this:
document.forms[0].elements['myelement']
So, I have to iterate through the elements to find my field and make a
change to the element properties
myfield = "myelement" ;
for ( i=0; i<document.form s[1].elements.lengt h; i++ )
{
if ( document.forms[1].elements[i].name == myfield )
{
document.forms[1].elements[i].class = "newstylesheetf ormat";
}
}
}
Why is the document.forms[1].elements[i].class property not accessible
using this method even though I specified it in the form?
If I wanted to iterate through the properties of the elements how would
I do this, like this?
for ( i=0; i<document.form s[1].elements.lengt h; i++ )
{
for ( j=0; j<document.form s[1].elements[i].properties.len gth; i++ )
{
alert(document. forms[1].elements[i].properties.nam e);
}
}
}