|
|
#1 (permalink) |
|
New Member
![]() Join Date: Mar 2007
Posts: 11
|
Let's say I have a page like this:
Code:
<html><body>
<table border="1"><tr>
<td>
left cell
</td>
<td>
right cell
</td>
</tr></table>
<a href="javascript:something()">Change Text</a>
</body></html>
__________________
- Misho |
|
|
|
|
|
#2 (permalink) |
|
New Member
![]() Join Date: Jun 2007
Posts: 6
|
Try this out
HTML Code:
<html> <head> <title>TEST</title> <style type="text/css"> #text0{display:none;} h5.textHead{cursor:pointer;cursor:hand/*IE*/;} </style> <script> function togDisplay(id){ var style = document.getElementById(id).style; style.display= (style.display=="block") ? "none":"block"; } </script> </head> <body> <table> <tr> <td> <h5 class="textHead" onclick="togDisplay('text0')">title of row</h5> <div id="text0">long paragraph of text goes here</div> </td> </tr> </table> </body> </html> this probaly isn't exactly what your looking for, but if you play around with it you should be able to make it suit your needs.
__________________
... ... ... Visit www.EaglesFreak.com for all the latest news, articles, player profiles, videos, and philadelphia eagles information.
|
|
|
|
|
|
#3 (permalink) |
|
New Member
![]() Join Date: Aug 2007
Posts: 14
|
<html>
<head> <script language="javascript"> function something(){ document.getElementById("cell_1").innerHTML = "Text modified in the first cell" document.getElementById("cell_2").innerHTML = "Text modified in the second cell" } </script> </head> <body> <table border="1"><tr> <td id="cell_1"> left cell </td> <td id="cell_2"> right cell </td> </tr></table> <a href="javascript:something()">Change Text</a> </body></html> Real simple straight forward way. Anyways you can modify more then text there you can even add html. Remember to use single quotes for any html added inside of javascript. Also \ any javascript langauge specific charecters. Last edited by jeverd01; 08-19-2007 at 07:37 AM. Reason: Better solution |
|
|
|
|
|
#5 (permalink) |
|
New Member
![]() Join Date: Sep 2007
Posts: 3
|
if you want to change event td tag.you can use method of getElementsBytagName.
<table border="1" id="mytable"> <tr><td> left cell </td> <td> right cell </td></tr> <tr><td>left cell</td><td>right cell</td></tr></table> <a href="javascript:go()">Change Text</a> <script> function go(){ var k=document.getElementsByTagName('table'); for(i=0;i<k.length;i++){ if(k[i].id=="mytable"){ var tbody=k[i].childNodes[0]; for(p=0;p<tbody.childNodes.length;p++){ tr=tbody.childNodes[p]; for(j=0;j<tr.childNodes.length;j++){ tr.childNodes[j].firstChild.nodeValue+="1"; } } } } } </script> |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|