javascript within php file

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am hoping someone can help me out.  I am trying to run javascript
within a PHP file.   The javascript works fine within a html file but
when I move it over to a PHP file it longer works.

Any ideas?  Is there specific order?

Thanks in advance!

Re: javascript within php file

Kent wrote:
Quoted text here. Click to load it

Javascript runs on the client; PHP runs on the server.

As long as you either output the javascript as you would if it were in  
an HTML file or echo/print it to the browser, it should work fine.  The  
client won't care.

But you didn't give us any code, and my crystal ball is broken, so it's  
hard telling what your problem might be.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: javascript within php file

Quoted text here. Click to load it

Thank God for friends like you Jerry.
I'm new at PHP also and got stuck on this, and duh... there it was.
I echoed "<script type="text/javascript">document.write("Hello
and Bingo!
Thanks again pal.
tony from

Re: javascript within php file

Quoted text here. Click to load it

->it happens because the php file execute first and after this html

->an you can say html page is in php code so when the html page is
going to refresh that time it call PHP script first so it is specific
that you put the javascript after php tag or between php and html

Site Timeline