3
Contributors
3
Replies
6
Views
5 Years
Discussion Span
Last Post by lps
0

If I am not mistaken, your question is on how to made the content change when a link is clicked, am I correct? If so, there are 2 ways of doing it.

  1. seperate the codes into multiple html and use php $_GET method with action preset to the link to get the correct content. eg.

    $page = $_GET['page'];
    if($page=="page1"){
    include('page1.html');
    }elseif($page=="page2"){
    include('page2.html');
    }

while the links will be

<a href="?page=page1">page 1</a>
<a href="?page=page2">page 2</a>
  1. load everthing and use jquery to display wanted area.(this will not work if the user deactivate the javascript of their browser)

    <a id="link_1" class="page" href="#">page 1</a>
    <a id="link_2" class="page" href="#">page 2</a>
    <div id="page1">page 1 content</div>
    <div id="page2">page 2 content</div>

jquery

//bind the click action of the links
jQuery('.page').live('click',function(){
    var id = jQuery(this).attr('id');   //get the id of the clicked link
    var num_array = id.split("_");      //an array to split the id into parts based on symbol "_"
    var content = "page"+num_array[1];
    jQuery(content).show();//show the required div
    jQuery(content).siblings().hide();// hide other div
    return false;//made the link with href not working
})

Edited by lps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.