Forum Moderators: open
<form>
.... form elements
</form>
<form >
.... form elements
</form>
forms[0].name='form1'
forms[0].name='form2' JAVASCRIPT CODE
foo( formName){
myForm = document.forms[ formName ];
myForm.style.visibility = 'visible';
...(several more operations with myForm)
} i read on quirksmode.org that using getElementById for forms might cause problems so i use forms[ '<name?' ].
Hhhmmm, I was not aware of this... unless may be you are wanting to support very old browsers with your forms, that don't support the newer DOM methods?! If you simply want to read values from your forms then the forms[] array is fine.
I think I found the page on quirksmode.org that you are referring to (or possibly an updated version), entitled "Extending forms" - regarding the dynamic creation of form fields using JS. However, it seems to suggest the contrary:
PPK:
Only using the W3C DOM you can allow your users to generate as many form fields as they need. This effect is impossible to mimic with any previous JavaScript technique.
:
:
Problems in Explorer
...the generated form fields are unreachable by a traditional document.forms call: Explorer simply doesn't enter them in the arrays. This can be worked around by giving the form field an ID and then using getElementById().
;)