<input type="button" id="blue" value="pick one" onClick="pickMyArray();" />
<br/>
<div id="output">
Hello Dr Eaglin! Please press the button to select student for automatic A for this class.
</div>
JavaScript
//can't seem to get this to work. Up top the buttton is set and onclick is calling the function.
// myArray is set globally
var myArray= [Kristopher, Ignacio, Vanessa, Charlene, Casey, Christian, Adnane,
Nicholas, Ronald, Andrew];
function pickMyArray()
{//random is set to randomly pick from myArray given its array length.
var random = myArray[Math.floor(Math.random() * myArray.length)];
//this gets random variable and assigns it to output
random=document.getElementById("output").innerHTML;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.