Jump to content

Archived

This topic is now archived and is closed to further replies.

capsulecore

Content Issue

Recommended Posts

Ive been looking for a way to open a link on a page without having the whole page reload. For example the link would be in the navigation, (part of the header include) and would swap out the include for the body:

<?php include(header.txt);?> //would have the link
[color=red]<?php include(home.txt);?>[/color] //link would change this to:  [color=green]<?php include(info.txt);?>[/color]
<?php include(footer.txt);?>

Is there any way to do this that isnt overly complicated? I've tried using layers but the layers wouldnt properly resize the page, same with iframes.

Share this post


Link to post
Share on other sites
Uhhhh you could do
[code=php:0]
$act = $_GET['act'];
if(!isset($act)) { $act = "home"; }
if($act = "home") { include("home.txt"); }
elseif ($act = "info") { include("info.txt"); }
else { echo "Inccorrect act."; }
[/code]
the page would have to reload for that though.... Youre best bet is using javascript i think...

Share this post


Link to post
Share on other sites
Much neater to use a swtch:
[code=php:0]// check that $_GET['act'] exists, if it does use its value, else set a defualt value
$act = isset($_GET['act']) ? $_GET['act'] : 'home';

// now we check the value of act
switch($act)
{
    // think of this as an if statement that says if $act is equal to home, or info or pruducts include $act.php
    case 'home':
    case 'info':
    case 'products':
        include $act . '.php';
    break;
    // and this as the else bit
    case defualt:
        die("Invalid value for act");
    break;
}[/code]

however the page will still reload to get the new content

Share this post


Link to post
Share on other sites

×

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.