I've been trying for hours to figure out how to refresh the <table>
with random values when a button is clicked. I've assigned id="myTable" to the <table>
and tried using the .reload() function, but it's not working. Any suggestions on how to make this work?
Click here for a DEMO on JSFIDDLE
Here's the HTML code:
<table id='myTable'>
<tr>
<td id="rand1"></td>
</tr>
<tr>
<td id="rand2"></td>
</tr>
</table>
<button onclick="parent.document.getElementById('myTable').reload()">Refresh the Random</button>
And here's the JavaScript code:
var Random = function() {
return Math.random();
}
document.getElementById("rand1").innerHTML = Random();
document.getElementById("rand2").innerHTML = Random();