Does anyone know which of the following is preferable for accessing an element, [tt]anElem[/tt], inside a form, [tt]aForm[/tt]?
Options (there may be more):
I believe that the last two are more cross-browser compatible than the first one, but I am not sure. I would lean toward the second one for form elements and the third one for anything else (but I'm not sure why). Does anyone know anything more about this?
--Chessbot
"Violence is the last refuge of the incompetent." -- Asimov, Foundation
Options (there may be more):
Code:
document.aForm.anElem;
document.forms['aForm'].elements['anElem'];
document.getElementById('anElem');
I believe that the last two are more cross-browser compatible than the first one, but I am not sure. I would lean toward the second one for form elements and the third one for anything else (but I'm not sure why). Does anyone know anything more about this?
--Chessbot
"Violence is the last refuge of the incompetent." -- Asimov, Foundation