/ Published in: JavaScript
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
window.onload = function(){
document.getElementById("randomButton").addEventListener('click', selectRandomOption, false);
}
function selectRandomOption() {
var box = document.getElementById('s_box');
box.selectedIndex=box.length-1;
box.selectedIndex=((Math.random()*box.length)-1);
};
Comments
 Subscribe to comments
                    Subscribe to comments
                
                