Forum Moderators: open

Message Too Old, No Replies

Dynamic content without page refresh

         

andrewsmd

3:09 pm on Dec 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So I have a page that I want to change dynamically on a link click without going to another page. Can someone show me the javascript.
Here is the page simplified
<html>

<body>

<table>

<tr>

<td><a href = "link1">Link 1</a></td>
<td><a href = "link2">Link 2</a></td>
<td><a href = "link3">Link 3</a></td></tr>

</table>
<div id = "content"></div>

</body>

</html>
Basically I want the div "content" to be filled with the output corresponding to link1 link2 etc. I would also like the link 1 or link 2 background to be changed by possibly changed what class it has based on when a user clicks it. However, if they click another link, I don't want it to stay so it needs to change back. I don't want to have to go to another page does anyone know the JS to do this? I am a PHP guy. Thanks,

coopster

9:41 pm on Dec 31, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't have time to develop the JS but I can offer direction. You can change your background by setting the onclick event handler for your links and then modify the background color style for the div.

If you don't want to go to another page but you want to load up the div with contents from a different page you are likely going to have to use some type of asynchronous call (AJAX).