What is difference between
document.getElementById(“selAge”)
document.myForms.selAge
When to use which?
document.getElementById() is the recommended way to get reference of elements. It's easier to use and also would not require any changes if you decide to change the Form name or Id. However, as it traverses the entire DOM tree, it is usually slower than the document.forms notation of referencing objects, so take this into account when doing a lot of such look-ups.
document.forms is also harder to use, as you need you to know the entire path to the object beginning from the document element.