View Full Version : innerHTML not working

May 17th, 2005, 06:48 AM
Have any ideas on how to get this code to work?

function over(which, id){

elementTest = "result"+id;
document.all.elementTest.innerHTML ="red";

The code is called when the mouse moves over cell 45
onMouseover="over(this, 16);

The grid cell I want to change is cell 16, when the mouse moves over cell 45.
<td ID="result16">16</td>

The code works if using the following is used instead of the passed in id.
document.all.result16.innerHTML ="red";

Thanks for any help,

May 17th, 2005, 10:38 AM
function over(which, id){
document.getElementById('result'+id).innerHTML ='red';

May 17th, 2005, 02:13 PM
If the onmouseover is in the cell, then using the this parameter is enough.

function over(which){
which.innerHTML ='red';
<td id="result16" onmouseover="over(this)">16</td>