Drupal: Run simple JS Scripts on a specific node
Let's say that you have a simple input form, on a specific node in your drupal site and you just want to reset it, using a button. There are a few ways you could go about it, but this one is probably the simplest one.
<ol>
<li>Initialize global variable <strong>$base_url</strong> to gain access to functions <strong>base_path()</strong> and <strong>path_to_theme()</strong>, so that you can generate the script's path dynamically. ie <pre><code><?php global $base_url; ?></code></pre></li>
<li>Proceed to generate the right relative path to your script ie <pre><code><?php print base_path().path_to_theme().'/js/myjs.js'?></code></pre></li>
<li>Override the appropriate template file ie node.tpl.php</li>
<li>You can now use your script's functions in the particular node ie <pre><code><input type="submit" value="" name="op" OnClick="clrForm()"></code></pre></li>
</ol>
<pre><code>
<head>
...
<?php print $scripts; ?>
<?php global $base_url; ?>
<script type="text/javascript" src="<?php print base_path().path_to_theme().'/js/myjs.js'?>"></script>
</head>
</code></pre>