I am trying to create a random number game. One of the elements that I need is a random number generator that allows the user to set the range of which the number will be chosen from. Currently I have this and it does not work. Any tips?
JavaScript
var min = document.getElementById("minNum").value;
var max = document.getElementById("maxNum").value;
function setRandomNum() {
document.write(Math.floor(Math.random() * (max - min));
}
HTML
<input type="text" id="minNum" name="minNum" />
<input type="text" id="maxNum" name="maxNum">
<input type="button" id="submitRange" name="submitRange" value="Set Range" onclick="setRandomNum()">
For now the document.write is there just to test if it works.