Jump to content

jq advanced question: random pick of an option after populating


Recommended Posts

not that the problem is advanced, but the fact, that the code probably features a minor error http://jsbin.com/apudev/9/edit what it does is randomly picks a car from one of two lists chosen by the user. the only thing is that the choice does not get reflected in the select field. so the four lines lines

var select = document.getElementById('s1');var items = select.getElementsByTagName('option');var index= Math.floor(Math.random() * items.length);select.selectedIndex = index;

which elsewhere would work do not fit in the rest. what could be wrong?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...