Jump to content

display html based on link clicked


davidcriniti

Recommended Posts

I have been trying to find a way to use php to display content in the main area of my page, based on a link clicked on the side of my page.

 

The closest thing to what I'm after is done with jquery: http://jsfiddle.net/5NEu3/3/

 

Was wondering how it would be done with php. Ie: What would I do with the table below, which has 3 links in the left column, and 3 sentences is the right. Each only to be displayed when their link is clicked, and hidden again if any of the others are clicked.

 

Any advice would be greatly appreciated.

 

Cheers,

 

Dave

 

<table width="100%" cellpadding="3">
 <tr>
   <td>
   <a href="???">Link 1 </a><br />
   <a href="???">Link 2 </a><br />
 <a href="???">Link 3 </a><br />
   </td>
   <td>

   Show if and when Link 1 is Clicked. Hide if anything else is clicked.

   Show if and when Link 1 is Clicked. Hide if anything else is clicked.

   Show if and when Link 1 is Clicked. Hide if anything else is clicked.


   </td>
 </tr>
</table>

Link to comment
Share on other sites

You could give each a link to the current page with a get variable set, then using php to process the get variable, display whichever line you want.

 

<a href="this.php?link=1">Link 1</a>

<?php
if(isset($_GET['link']) && $_GET['link'] == '1'){
echo "Show if and when Link 1 is Clicked.....";
}
?>

 

You could expand on that for the rest. Obviously this will require a page refresh.

 

If you want to do with without a page refresh, then you'll need to look at using AJAX, which means you'll have to use javascript as well..

 

Denno

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.