[Solved] easy javascript code not working [closed]


I have found couple of issues here.

You have two form tags which is un-necessary and the form tags needs to have a name and id. Atleast name attribute must be there.

Check the following fiddle

http://jsfiddle.net/ayyadurai/3Ru9T/

  <form name="form1" id="form1">
  <input type="button" id="button" value="click" onClick="what()" />

   <input type="text" id="text" value="hey" />
  </form>




var button = document.getElementById("button");
var div = document.getElementById("box");
var text = document.getElementById("text");
var array=[ "thanks for clicking", "keep on clicking", "click one more time", "why do you keep on clicking me?", "stop clicking me!"];


function thing(){
var y = array[Math.floor((Math.random() * array.length)+1)];
form1.text.value=y;

}

function what(){
form1.text.value = "what"; 
            thing();

}

solved easy javascript code not working [closed]