How to add javascript files to Drupal

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by jruffino on November 23, 2010 at 8:41pm

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

Posted by hershel on November 24, 2010 at 10:43am

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

Posted by jruffino on November 24, 2010 at 4:19pm

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

Posted by hariharasuthan_mk on February 18, 2011 at 12:44pm

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:

AltStyle によって変換されたページ (->オリジナル) /