Document.getElementById ("selAge") Vs document.myForms.selAge
document.getElementById () is the recommended way to get a reference to elements. It is easier to use and also doesn't require any changes if you decide to change the form name or ID. However, since it traverses the entire DOM tree, it tends to be slower than document.forms notation of object references, so keep that in mind for a lot of such requests.
document.forms is also more difficult to use, since you need to know the entire path to the object starting at the document element.
source to share
The second is an absolute no-no! It first finds an element with id / name "myForms" and gets its child with id / name "selAge". The first one finds any element with the identifier "selAge". Always use the first ... because someone in the future might decide to put "myForms" in a div. Then you have a fix.
source to share