AJAX Forums

How to Add Javascript code into a PHP file?

This is a discussion on How to Add Javascript code into a PHP file? within the JavaScript forums, part of the Beginners AJAX category; I am not a programmer by any sense of the word.I am able to edit website files extensively, more so with HTML files.However, I am not understanding how ...


Go Back   AJAX Forums > Beginners AJAX > JavaScript

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Old 06-14-2007, 09:09 AM   #1 (permalink)
Junior Member
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0 Colleen M is on a distinguished road
How to Add Javascript code into a PHP file?

I am not a programmer by any sense of the word.I am able to edit website files extensively, more so with HTML files.However, I am not understanding how to insert this piece of Javascript code into a file which is PHP.Can someone please explain to me how to do this, in a "see spot run" format?I really appreciate your help.Colleen
__________________
Colleen M is offline   Reply With Quote
Old 06-14-2007, 06:38 PM   #2 (permalink)
Junior Member
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0 Smoothcat is on a distinguished road
put it between the head tags on the source code. Make sure the javascript is between the script tags:code...
__________________
Smoothcat is offline   Reply With Quote
Old 06-15-2007, 08:57 AM   #3 (permalink)
Junior Member
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0 Julis is on a distinguished road
You should just be able to insert it into the script. Thats what I do with my PHP files on my website. To test it out, make a PHP page (a sample PHP website page, with a few words and links and such) and then add a Java from a place like http://www.dynamicdrive.com or http://www.javascriptkit.com (make sure that the script says that it has been tested and will work in the browser you are trying to use) and test it out.Also, it will not work if your server blocks either PHP or Java.Good luck!
__________________
Julis is offline   Reply With Quote
Old 06-15-2007, 11:48 AM   #4 (permalink)
Junior Member
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0 soheilnb is on a distinguished road
PHP has not changed the shape of HTML tags and codes in any way, so you can insert a piece of javascript code into a php file exactly the same way you do it in html file. PHP only allows you to mark certain parts of a php file as php code which will be interepreted by php program before it is send to the client browser.To insert a javascript code, do it inside ... as usual, but make sure it is not inside special php tag.RIGHT: // your code ...WRONG:
__________________
soheilnb is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Can I use javascript in an XML file? hazoura_87 XML and XSLT 0 11-30-2007 02:57 AM
Can it be possible to open an xml file and view it as 'code and design'type? rickey p XML and XSLT 1 11-25-2007 07:21 AM
HTML code to write an XML file? cjbrx3115 XML and XSLT 0 11-18-2007 05:15 PM
How can I create an xml file in my code using vb.net? Sheena W XML and XSLT 1 11-09-2007 10:57 AM
javascript code submission form aktarerz JavaScript 0 06-17-2007 10:21 PM


All times are GMT -4. The time now is 07:06 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5
Copyright ©2006 - 2008, AJAXwith.com