Posted By

doorhammer on 12/25/10


Tagged

javascript


Versions (?)

random selector


 / Published in: JavaScript
 

  1. window.onload = function(){
  2. document.getElementById("randomButton").addEventListener('click', selectRandomOption, false);
  3. }
  4.  
  5. function selectRandomOption() {
  6. var box = document.getElementById('s_box');
  7. box.selectedIndex=box.length-1;
  8. box.selectedIndex=((Math.random()*box.length)-1);
  9. };

Report this snippet  

You need to login to post a comment.