manipulating the table cell's data with js...

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

manipulating the table cell's data with js...

Post by lostboy »

is it possible?

ex. want to insert a date into a table cell...easy with asp/php etc. but want to do this with js...how do i refer to that table cell to show the current date/time?

TIA
Rob the R
Forum Contributor
Posts: 128
Joined: Wed Nov 06, 2002 2:25 pm
Location: Houston

Post by Rob the R »

It is. I found a web page that describes this. I tested it on my browser (Safari), and it worked great! That website claims this works in all sorts of browsers. I tested it with this:

Code: Select all

<table>
   <tr>
      <td><span id="cell">One</span></td>
   </tr>
</table>

<a href="javascript:document.getElementById('cell').innerHTML='One';">One</a>
<br>
<a href="javascript:document.getElementById('cell').innerHTML='Two';">Two</a>
<br>
<a href="javascript:document.getElementById('cell').innerHTML='Three';">Three</a>
I should think you could use the "innerHTML" technique from any Javascript code, and not just the test links I used above.
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

lostboy,
Check out this thread. The first example worked for me.




John M


viewtopic.php?t=1192
Post Reply