I’m making a page that should display the variable of my choosing within a table. I did the same thing twice, changed the id’s and cuch, but only one works. I spent an hour looking over the syntax, and redoing allot of the work but it just doesn’t help. Here’s the three main pieces of code:
var NewGlad = new Array("Jokomopo","Etony","Roy");
var BestGlad = new Array("Johnny","Cod","Billy");
function UpdateTable(){
document.getElementById("0New").innerHTML = "<a href='" +NewGlad[0]+ "'>" + NewGlad[0] + "</a>";
document.getElementById("0Best").innerHTML = "<a href='" +BestGlad[0]+ "'>" + BestGlad[0] + "</a>";
}
//The function above IS executed onLoad.
Here’s the html, I’ll just show you the table row we’re dealing with:
<tr>
<td class="NewestGlads" id="0New">
fgggrf
</td>
<td class="BestGlads" id="0Best">
fgggrf
</td>
</tr>
Only the NewestGlads td is updated. The other still displays “fgggrf”
Don’t say this should be easy. If it were easy you would not be asking us for the answer. You code could use some refinement:
I changed your references so that they are starting with an alpha character instead of a number. Your HTML will need to change to match. I have never seen identifiers starting with a number and believe it to be a bad convention that could be error prone cross browser. Try this instead by calling the UpdateTable function. You can also execute this without a call by making the code as follows: