I'm trying to create JS script that will generate random numbers between 2 values. But it doesn't work and I can't figure out why.
<form id="form" action="" method="get">
From: <input type="text" name="from" id="from"><br>
To: <input type="text" name="to" id="to"><br><br>
<button onclick="random_gen()">Generate</button>
</form>
<script>
function random_gen() {
var a = document.getElementById("from").value;
var b = document.getElementById("to").value;
var c = Math.floor((Math.random() * b) + a);
document.getElementById("final").innerHTML = c;
return false;
}
</script>
<p id="final"></p>
PS I'm new at JS
<button type=button ....innerHTML = c;isn't happening. Then again, this may not be the problem the OP has at all