I have a <select> element with units of lengt in it. I have writen a javascript code, that should have printed the next value of the select, but it just sleects the next and prints the current one.
var select = document.form.unit; var value = select.options[select.selectedIndex++].value; document.form.output.value = value;
You have used post increment on selectedIndex. That's why variable value stores value of selected item. Modify your code to this:
var select = document.form.unit;
select.selectedIndex++;
var value = select.options[select.selectedIndex].value;
document.form.output.value = value;