Using custom javascript files

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

Having only begun working with Drupal about 6 weeks ago it is a robust platform but there is a real learning curve in regards to how to do things. Although the use of jquery is great (especially appreciate the jscalendar) this is focused outside of that resource.

The issue here is that the web site mockup was created using HTML and Javascript. Most of the processing logic resides in the developed javascript. How then do you adapt these javascript files?

The question is if a custom content type is created using CCK fields how do you simulate the value in those fields? How does "var numChar = form3.InputVal[3].value" translate into Drupal? Also instead of a "submit" button how can the "save" button simulate this action.

Although the scripts[]=javascriptfile(s).js in the theme.info file can be used globally is there a way to localize this only to a particular content type?

Kind of have three inter-related questions. Am not averse to using or modifying PHP but preference (if possible) is to just use javascript.

TIA.

Comments

The question is if a custom

Garrett Albright's picture

The question is if a custom content type is created using CCK fields how do you simulate the value in those fields? How does "var numChar = form3.InputVal[3].value" translate into Drupal?

What you're basically asking here is, "How do I use jQuery?" - so you're not focused outside of that resource at all. I will point you to the jQuery docs page, or the jQuery Book if you learn well from dead trees. The Drupal Book also has a section on jQuery and specifically how it is used with Drupal.

Although the scripts[]=javascriptfile(s).js in the theme.info file can be used globally is there a way to localize this only to a particular content type?

The best way would be to write a custom module which attaches the JavaScript file only if a node of that type is being loaded, but if you want to avoid PHP… Many themes, when a node is being viewed, will add a class of "node-type-(page|story|etc)" to the body tag. You could use that to check whether the desired nodetype is being viewed entirely from within JavaScript.

Thanks for clarifying

ekierklo's picture

My thanks to you Garrett and the Drupal community for helping focus on this topic. Will research jQuery.

Edward

JS Injector

Javascript

Group notifications

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