Newbie Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jp_css
Forum Newbie
Posts: 23
Joined: Thu Dec 04, 2003 3:20 pm

Newbie Question

Post by jp_css »

I was wondering if there could be a way, PHP preferably, to have a javascript execute and to obtain the html from that rendering and placing that html onto a page. I have tried to read from a file, but of course it has been giving me the exact code(javascript) of the page. Any ideas, suggestions, etc. would be helpful.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

could you be more specific? you confused the he1l outta me!
jp_css
Forum Newbie
Posts: 23
Joined: Thu Dec 04, 2003 3:20 pm

Post by jp_css »

Ok. Here is a sequence of events that I would think could work, it is just that I don't know how to do it. Maybe somebody could help:

1. Someone visits a webpage
2. This site has a javascript that generates a table
3. The javascripts executes possibly elsewhere in a php file
4. The html generated by the javascript is passed from elsewhere and included into the page that the user is looking at.

Thus, in the source we have the html version of the code.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

ok, so like put your javascript in a PHP page, and then use the include() and include taht php page where ever you need...

Code: Select all

include("javascripts.php");
jp_css
Forum Newbie
Posts: 23
Joined: Thu Dec 04, 2003 3:20 pm

Post by jp_css »

Well that is what I am saying doesn't work. It's pretty easy to include the javascript, but if you look in the source it is still the javascript. I want the javascript to be render first, then place that actual html into the page.
jp_css
Forum Newbie
Posts: 23
Joined: Thu Dec 04, 2003 3:20 pm

Post by jp_css »

Anyone have any clue?
User avatar
Ixplodestuff8
Forum Commoner
Posts: 60
Joined: Mon Feb 09, 2004 8:17 pm
Location: Queens, New York

Post by Ixplodestuff8 »

Javascript is a client-side language, you can't hide it normaly. I did a google search for "server side javascript" and got some results, look into it.
jp_css
Forum Newbie
Posts: 23
Joined: Thu Dec 04, 2003 3:20 pm

Post by jp_css »

Would it be possible at all to load the javascript in a seperate file so that when someone loads a page, the javascript is processed, then to copy the html from that process into the real page?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

you could use

<script src="javascript_page.js" type="text/javascript"></script>

and fi you put that at the top of your page, that'll be the only thing visible int he view source...
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

only solution is to have 2 pages

one does all your stuff, then transfers them (window.location) to page2.php?var1=value&var2=value, etc, then those variables would become accesible in PHP
Post Reply