Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Controlling table content with links

Posted on 2003-10-24
12
Medium Priority
?
155 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
10 Comments
 
LVL 8

Accepted Solution

by:
fozylet earned 152 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 148 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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
 
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

824 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