Solved

Controlling table content with links

Posted on 2003-10-24
12
147 Views
Last Modified: 2010-04-09
Hello

Is it possible to control the contents of a table within an html page with links and if so how?. I know you can control frame content but I wanted to change the information within a particular table when the viewing clicks on a menu link.

Thanks

Reidy

0
Comment
Question by:reidy
  • 4
  • 3
  • 2
  • +1
12 Comments
 
LVL 8

Accepted Solution

by:
fozylet earned 38 total points
ID: 9614531
Use a div inside the table. Here is a sample code.

<html>
<head>
<SCRIPT language="javascript">
function swapText(obj) {    
obj.innerHTML = "Dynamic Content";
}    
</SCRIPT>
</head>
<body>
<table><tr><td>
<div id="dynCont">
Initial Text
</div>
</td></tr></table>

<a href=# onClick="javascript:swapText(dynCont)">Try Me!</a>
</body>
</html>
0
 
LVL 4

Assisted Solution

by:apprenti
apprenti earned 37 total points
ID: 9614964
I think you need the quotes:

<html>
<head>
<SCRIPT language="javascript">
<!--
function swapText(obj) {    
document.getElementById(obj).innerHTML = "Dynamic Content";
}    
// -->
</SCRIPT>
</head>
<body>
<table><tr><td>
<div id="dynCont">
Initial Text
</div>
</td></tr></table>

<a href="javascript://" onClick="swapText('dynCont')">Try Me!</a>
</body>
</html>
0
 
LVL 8

Expert Comment

by:fozylet
ID: 9615006
We are not passing a string, it is an object variable.
Putting quotes to it will change it to a string, i guess.
note that our javascript codes are differend and I use an object while you use the object name.
0
 

Author Comment

by:reidy
ID: 9615410
Hello fozylet and apprenti

Thanks I got both of your scripts working ok but I can't seem to get the text to appear over multiply lines, basically I wanted to have scrollable text paragraphs within the table or even several images. I don't know if this is possible as I' new to html and javascript.
0
 
LVL 4

Expert Comment

by:apprenti
ID: 9615450
Have you tried moz.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:apprenti
ID: 9615460
...My copy of moz does not run fozylet's.
0
 
LVL 4

Expert Comment

by:apprenti
ID: 9615498
"Dynamic<br> Content"
+"More dynamic<br>Content"
0
 
LVL 8

Expert Comment

by:fozylet
ID: 9615678
did not try moz... tested only on IE
getElementById is the recommended way to go, i think
0
 

Author Comment

by:reidy
ID: 10662678
yes I agree with the comment from mplungjan with regards to splitting the points
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 10664712
So feel free to do it...
Please click split points above the entry field and follow instructions
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now