Solved

Controlling table content with links

Posted on 2003-10-24
12
146 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 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

20 Experts available now in Live!

Get 1:1 Help Now