I've seen the question "How does one determine selected option value in a HTML SELECT control" asked more times than I care to count - this and this and this for instance.
These questions all have something in common, they usually suggest one of the following methods:
//Method 1
document.getElementById("SelectControlsID").value;
OR
//Method 2
document.getElementById("SelectControlsID").options[document.getElementById("SelectControlsID").selectedIndex].value;
Question 1: I presume Method 2 is a relic from the past needed for some archaic browser that doesn't support calling .value
directly? If so, which browsers still require the options[]
method? Is this an ECMAScript spec issue?
Question 2: When writing new code, is it safe to just use Method 1 or is Method 2 still advisable (JQuery aside)?