Add JavaScript From a Module

The following bit of code will add your javascript file to the page.

// get the path to the module
$mod_path = drupal_get_path('module', 'YOUR_MODULES_NAME');
// add the functions.js file where all the javascript will be located
drupal_add_js($mod_path .'/functions.js');

Include the required Google file for mapping

$maps_url = "<script src=http://maps.google.com/maps?file=api&amp;v=2&amp;key=" .
$YOUR_KEY . " type='text/javascript'></script>";
drupal_set_html_head($maps_url);

Here is how you can make a PHP variable available to your JavaScript functions.

$phpvariable = "some_value";
drupal_add_js("var startZoom = " . drupal_to_js($phpvariable) . ";", 'inline');

Contact Me

Feel free to contact me.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.