View Single Post
Old 02-14-2013, 07:13 PM   PM User | #8
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
Lightbulb

And alternatively...
Code:
<!DOCTYPE HTML>
<html>
<head>
<title> Untitled </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>
<body>
<form>
<div id="debugger"></div>
<p>
<select id="s1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option> <option>5</option> <option>6</option>
</select>
</form>

<script type="text/javascript">

var arr = [0,1,2,3,4,5];
var str = '';
for (var i=0; i<10; i++) { 
  arr.sort(function() { return 0.5 - Math.random();});
  str += arr.join(', ')+', ';
}
document.getElementById('debugger').innerHTML = str;


var select= document.getElementById('s1');
arr.sort(function() { return 0.5 - Math.random();});
select.selectedIndex = arr[0];

</script>
</body>
</html>
jmrker is offline   Reply With Quote