So far I get a random word from the list every time I refresh the page, however I want to be able to generate a random word in the textbox with the "show" button. How do I do that? I suppose I should switch out document.write with something else? I've tried onclick instead but it did not work.
var words = [
  'Hello',
  'No',
  'Hi',
  'Banana',
  'Apple'
];
function randomWord(words) {
  return words[Math.floor(Math.random() * words.length)];
}
for (var x = 0; x < 1; x++)
  document.write(randomWord(words));<form name="f1">
  <input type="text" value="" name="textbox" id="textbox" />
  <input type="button" value="show" onclick="randomWord()" />
  <br/>
</form>
<div id="new" /> 
     
     
    