<meta charset="utf-8"><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
If you don&#39;t care that it&#39;s on every page, couldn&#39;t you just add it to<br>the .info file of the theme?</blockquote><div><br></div><div>You could, but then the JS is dependent on the theme. Switching the theme or usage of an admin theme could affect the functionality.</div>
<br><div class="gmail_quote">On Wed, Mar 2, 2011 at 2:48 PM, Anthony Malkoun <span dir="ltr">&lt;<a href="mailto:malkouna@yahoo.com.au">malkouna@yahoo.com.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
If you don&#39;t care that it&#39;s on every page, couldn&#39;t you just add it to<br>
the .info file of the theme?<br>
<div class="im"><br>
On 6:59 AM, Carl Wiedemann wrote:<br>
&gt; If you don&#39;t care that the JS is added on every page, you might as<br>
&gt; well put it in hook_init. Otherwise if you want to use the same JS on<br>
&gt; multiple forms you would need multiple #after_build or #theme<br>
&gt; callbacks, which is repetitive and a little messy. Write your JS so<br>
&gt; that if indicative elements aren&#39;t present in the DOM it returns early.<br>
&gt;<br>
&gt; On Wed, Mar 2, 2011 at 6:53 AM, Joel Willers &lt;<a href="mailto:joel.willers@sigler.com">joel.willers@sigler.com</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:joel.willers@sigler.com">joel.willers@sigler.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     I’m looking to do calculations between CCK fields.  I’ve found<br>
&gt;     some cool ways to add Javascript to a page, but before I get too<br>
&gt;     far into this, I figured I’d ask for some quick advice to see if<br>
&gt;     there was a better way.<br>
&gt;<br>
&gt;     Basically, I’m looking to do math on an ‘onchange’ event.  If<br>
&gt;     Field A is set (base) and Field B is changed, Field C and D<br>
&gt;     automatically update.  Similarly, if C changes, B and D update,<br>
&gt;     and same for D changing B and C.  I’m planning to use the<br>
&gt;     technique described at:<br>
&gt;<br>
&gt;     <a href="http://switchbackcms.com/blog/right-way-include-javascript-your-drupal-form" target="_blank">http://switchbackcms.com/blog/right-way-include-javascript-your-drupal-form</a>,<br>
&gt;     but at <a href="http://drupal.org/node/322290" target="_blank">http://drupal.org/node/322290</a> (#7) there is talk of adding<br>
&gt;     a theme function, which I’m guessing I could do using a nice<br>
&gt;     tpl.php file.<br>
&gt;<br>
&gt;     Any suggestions are welcome, especially if there is an already<br>
&gt;     existing module for field relationships.<br>
&gt;<br>
&gt;     Joel<br>
&gt;<br>
&gt;     **<br>
&gt;<br>
&gt;<br>
&gt;     --<br>
&gt;     [ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
&gt;<br>
&gt;<br>
</div>--<br>
<div><div></div><div class="h5">[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</div></div></blockquote></div><br>