Skip to content Skip to sidebar Skip to footer

Random Selection In Combobox?

I need to know how could do to make a combobox to display a different selection each time you load the page, not create them, if not to show the options that exist, each time you l

Solution 1:

This should do the trick:

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

select.selectedIndex = index;

http://jsfiddle.net/lakario/dHLax/

Post a Comment for "Random Selection In Combobox?"