Jump to content

Using Javascript To Change Php Include Page?


kensbeijing
 Share

Recommended Posts

Is it possible to use javascript to decide which page to include() in php?I have a row of 4 links, each link should change the include() page (in php) of a page without having to reload. So i need something like this:

<a title="link 1" onclick="<?php include('page1.php') ?>"><a title="link 2" onclick="<?php include('page2.php') ?>"><a title="link 3" onclick="<?php include('page3.php') ?>"><a title="link 4" onclick="<?php include('page4.php') ?>">

If you see what I mean...But most importantly I need it to not have to reload the page, and be able to keep changing page when you press the button.Thanks.

Link to comment
Share on other sites

jl is correct. And I recall your asking about AJAX, so I'll assume some of that stuck. As you describe, a user clicks on a link or something, and that sets the AJAX process in motion. Javascript sends a request based on what the user clicked. The targeted PHP script grabs the corresponding file and echoes it. Back on the client browser, the AJAX callback function gets the file data in AJAX.responseText, and assigns it to some element's innerHTML.FWIW, I've been working on a series of AJAX demos. (Not quite ready for prime time.) This one has more than you want, but the "quotes" section exactly illustrates the kind of thing you mean.http://www.sophox.com/sophox/ajax/sampler.htmlRelevant source files in human readable-form:http://www.sophox.com/sophox/ajax/demo.php.txthttp://www.sophox.com/sophox/ajax/poe.php.txt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...