I have a DropDown list named as batches.
If I selected 2nd option,dropdown.selectedIndex inside the OnChange function always shows the selected index.
But document.getElementById("batches").selectedIndex always shows the 1st index.
Why is this?
Actually I want read the correct selectedIndex of batches in another function that's why I need a way to get the correct selected index in both ways.
function OnChange(dropdown){
var myindex = dropdown.selectedIndex;// This prints correctly
alert("Index : "+document.getElementById("batches").selectedIndex);// This is always 0 no metter what selects
}
<select name='batches' id='batches' onchange='OnChange(this);'>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>