How to add javascript files to Drupal

Events happening in the community are now at Drupal community events on www.drupal.org.
jruffino's picture

I am working with a form that is heavily coded with JavaScript, and before our upgrade, my js links worked, now that we upgraded to Drupal 6.19, nothig works, all of my js/css links are gone. I have done research and found the drupal_add_js for php. My question is where do I put this (documentation and discussions are not very forthcoming)? I have 6 js and one css script to incorporate into my form. Any help would be appreciated.

I am linking to my css and js using:

    <link rel="stylesheet" href="http://storytubes.info/drupal/sites/default/files/js_css/storytubes.css" type="text/css" />
    <script type="text/javascript" src="http://storytubes.info/drupal/sites/default/files/js_css/st_title_bar.js"></script>
    <script type="text/javascript" src="http://storytubes.info/drupal/sites/default/files/js_css/st_tip_text.js"></script>
    <script type="text/javascript" src="http://storytubes.info/drupal/sites/default/files/js_css/storytubes.js"></script>
    <script type="text/javascript" src="http://storytubes.info/drupal/sites/default/files/js_css/st_validation2.js"></script>
    <script type="text/javascript" src="http://storytubes.info/drupal/sites/default/files/js_css/validation.js"></script>
    <script type="text/javascript" src="http://storytubes.info/drupal/sites/default/files/js_css/ajaxcore.js"></script>

The non-working node for the form is: http://storytubes.info/drupal/node/33

The working form is: http://www.storytubes.info/entry_form_drupal.html

Thanks

Comments

drupal_add_js is meant to be

hershel's picture

drupal_add_js is meant to be used in a module. You could make a custom module to do this.

Or you could just add that HTML to the webform itself, in the body...

--
CiviHosting -- Drupal and CiviCRM Hosting Specialists -- 100% Satisfaction Guaranteed

Thanks

jruffino's picture

I added it to the body, and it worked great! now all I need to figure out is why it is showing up weird.

Joseph A. Ruffino
Gail Borden Public Library District
Information Technology Technician
270 N. Grove Ave.
Elgin, IL 60120

add javascript in drupal

hariharasuthan_mk's picture

drupal_add_js(drupal_get_path('module', 'custom') . 'js/custom.js');

drupal_add_js(drupal_get_path('module','helper') . '/js/helper.js');

drupal_add_js('alert("checking!")', 'inline');

for more information visit :

http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad... <= drupal 7
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad... <= drupal 6
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad... <= drupal 5

Javascript

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: