...

View Full Version : Changing cell contents on the fly...



imanta
04-12-2005, 05:53 PM
I am wondering if it is possible to change table contents dynamicall in Javascript. I know I can change background color and others, but can you change the entire contents and even the class? Take the following:



<table id="colors" name="colors">
<tr>
<td id="cellA" class="red">red</td>
<td id="cellB" class="blue">blue</td>
</tr>
</table>


Now I want to change the contents of cellA and class of cellA to green. Any ideas?

Thanks in advance.

A1ien51
04-12-2005, 06:27 PM
Basic idea:

var objElem = document.getElementById("theId");
objElem.className = "newClass";
objElem.innerHTML = "new text";

Eric

imanta
04-12-2005, 06:43 PM
Duh... innerHTML got it...

How about changing an img src on the fly through JS? Any idea?

A1ien51
04-12-2005, 06:46 PM
objElem.src = "blah.gif"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum