Forum Moderators: coopster

Message Too Old, No Replies

Newbie Question - How to add popup javascript to index.php page code

PHP coding

         

Anto

5:32 pm on May 20, 2008 (gmt 0)

10+ Year Member



Hello I am new to PHP pages and I would like to know how to add a popup javascript to my homepage which is index.php.

The javascript is as follows:

<script type="text/javascript" src="http://forms.example.com/form/86/1985011386.js"></script>

And my index.php is as follows:

<?php
/**
* Sites index page
*
* File showing the home page of the site.
*
* PHP version 5.0
*
* @category###Framework###
* @package###Index###
* @author
*/
/**
* File having common configuration variables required for the entire project
*/
require_once('common/config.inc.php'); //configurations
require_once('common/configs/config_video.inc.php');
require_once('common/configs/config_photo.inc.php');
$CFG['db']['is_use_db'] = true; //reset any global vals
$CFG['lang']['include_files'][] = 'includes/languages/%s/index.php';
$CFG['html']['header'] = 'includes/languages/%s/html_header-NEW.php';
$CFG['html']['footer'] = 'includes/languages/%s/html_footer.php';
$CFG['mods']['include_files'][] = 'common/classes/class_FormHandler.lib.php';
$CFG['mods']['include_files'][] = 'common/classes/class_MediaHandler.lib.php';
$CFG['mods']['include_files'][] = 'common/classes/class_RayzzHandler.lib.php';
$CFG['page']['middle'] = 'general/index.php';
require($CFG['site']['project_path'].'common/application_top.inc.php');
//require_once('general/index.php');
?>

---------------------

Can you show me how to place it correctly in the index.php page? Or should it actually go into one of the other pages like "includes/languages/%s/index.php"?

Thank you so very much for your assistance.

[edited by: eelixduppy at 6:09 pm (utc) on May 20, 2008]
[edit reason] please use example.com [/edit]

eelixduppy

6:57 pm on May 20, 2008 (gmt 0)



Hello and Welcome to WebmasterWorld!

I am not exactly sure what you are looking for. If you want to add javascript to a php page you have two options. You can echo out the javascript from php itself using print() or echo(), or you may close the php tags and use the javascript how you normally would on a regular html page.

Anto

7:10 pm on May 20, 2008 (gmt 0)

10+ Year Member



Hi eelix,

I am sorry I am not familiar at all with PHP and commands like echo or print. I do know how to add this script on a html page and it works fine. It is just with php where I don't know how to get it to work.

Would you be able to show me what the code looks like?

Thank you so much.

eelixduppy

7:17 pm on May 20, 2008 (gmt 0)



Add this either before
<?php
or after
?>
:

<script type="text/javascript" src="http://forms.example.com/form/86/1985011386.js"></script>

Or add the following between those two tags:


echo '<script type="text/javascript" src="http://forms.example.com/form/86/1985011386.js"></script>';

Anto

9:23 pm on May 20, 2008 (gmt 0)

10+ Year Member



Hi eelix,

The echo format did the trick. Yahoo! It is working perfectly now. Thank you so much for your kind assistance. It is very much appreciated.

Have a great day!