PDA

View Full Version : innerHTML not working



wheelwinner.com
May 17th, 2005, 05:48 AM
Have any ideas on how to get this code to work?
<pre>

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";

</pre>
Thanks for any help,
http://www.wheelwinner.com

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

glenngv
May 17th, 2005, 01: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>