PDA

View Full Version : How can we display the content of a variable in a table cell??


HappyTomato
12-04-2002, 01:00 AM
if we have a table cell like the following:

<td id="link1" width=80% >Box 1.1</td>

and would like to change the content of the cell by using an address of a variable i.e. forms[2].name or array[i] etc in place of "Box 1.1" ..... how can we do that? or CAN we do that?

Any help would be appreciated.:)

Bo & Vic

glenngv
12-04-2002, 01:13 AM
document.getElementById("link1").innerHTML=variable;
or you can use DOM

ez4ne12c
12-04-2002, 01:19 AM
I would do that by using the
innerHTML property.

try this


<html>
<head>

<script>
function changeme()
{ link1.innerHTML='Balls 1.6';
}
</script>

</head>
<body>
<td name='link1' 'width=80%>
<span id='link1' onClick='changeme();'>
Box 1.1
</span>
</td>
</body>
</html>

That is 'the way i would do it'
i havent checked if this code works but that is how i change data in my tables

hope this helps
ez
ps innerHTML is supported by NS but implementation varies slightly

ez4ne12c
12-04-2002, 01:20 AM
hmmmmmmmmmm.....
why am i not surprised that glenngv did the same thing in one line
hahahaha
:D
ez

Mr J
12-04-2002, 07:12 PM
Experience

:D