Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

include PHP file using Javascript

Status
Not open for further replies.

krappleby025

Programmer
Sep 6, 2001
347
NL
Hi All,

i wonder if someone can help me.. I do not know java script and am looking to buy a book on it.. but for now i have what is probably a simple question

i have a php page.. which i need to include on many different website, including ASP, PHP and HTML sites now as you know PHP will not work on ASP sites, etc.. so i need a way to incorporate the page results into the new site

To do this, i thought about processing the page on my server, and then just including the results in the new site.. so that is what i did..

the page Called "showlinks.php" runs and generated just html code which can be then placed inot another site.. now

i need to know what javascript code, to use, to pull this file to there site..

I tried

<script src="
This generates just a list of HTML formated links, but when i place that code on a site, it comes up with an error..

can someone help

Cheers
 
php is server-side code.
javascript is client side code.

while you can programmatically determine what javascript files to include in a php file, you cannot programmatically determine what php files to include in a js file.

this is because js runs on the client, after the server has already processed any data and sent information to the client.

*cLFlaVA
----------------------------
[tt]Sigs cause cancer.[/tt]
 
how about an <iframe>????

Known is handfull, Unknown is worldfull
 
no iframe is not an option due to this being for SEO.. the links have to appear in the page itself, and not via an iframe
 
how about trying to open the file over the net, e.g: fopen() command in PHP that can be used to open urls and get back the HTML output only...

Known is handfull, Unknown is worldfull
 
I am thinking what you are perhaps asking for is something like this:

Use this in the file and in the position where you want the html translated php to appear:

<script language="JavaScript" type="text/javascript" src="html.js">
</script>

In html.js simply wrap the html code that you wish to include in:

document.write('
html here
')

You may have to check that there is no conflict with single quotes in the html

Clive
 
there is a tool where you can pass the data dynamically to a php page and then get results back through a javascript object (like an array, acts the same way, only you access the attributes through reference. ex: myObj.user_name is located in myObj['user_name']) the page is here:
however the page is in french so unless you can read that, just download the examples here:
it is a wonderful tool, if you need any help feel free to ask
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top