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

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">
<td id="cellA" class="red">red</td>
<td id="cellB" class="blue">blue</td>

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

Thanks in advance.

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

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


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

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

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

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum