Forum Moderators: open
Storing the random number inside the array is working properly but I can't put the value inside the a table in a separate HTML file.
Inside the .js file, this is the part that prints the value to the table of the html file .
document.getElementById("nos1").innerHTML = rnos[0]
document.getElementById("nos2").innerHTML = rnos[1]
Inside the html file, I have a table where I wanted the numbers to appear, but it is not working. Aside from that I don't want the numbers to appear inside the <p></p> tags because it put spaces. I only wanted it to appear inside the <td></td> tags. But I don't know how to make it appear inside the table that's why I use the <p> tags and put an ID in it.
<td class='bbox1'><p id="nos1"></p></td>
<td class='bbox1'><p id="nos2"></p></td>
<a href="javascript:GetRandomNow()">Random numbers</a>
This code isn't working.
Is there a way that it would work like a PHP variable where I just have to echo the variable name ?
Any suggestions please ?
Thanks.
put the value inside the a table in a separate HTML file
Assuming the file in question is the currently loaded page (onload event has fired) your code looks Ok. It will not work if executed to early or "file" is within a frame.
The PHP variable works while the page is being generated, in this case the page (file) preexists.