title: How to avoid this javascript eval()?
body: <p>I'm trying to rid my code of a couple of <code>eval</code>s that I have in my javascript, but I'm not sure of the best way to achieve what I'm trying to do.</p>
  
  <p>I have a "filter form" on a bunch of my pages, with a bit of JS attached to it that reloads parts of the page depending on what the user does.</p>
  
  <p>Different pages require different actions though.</p>
  
  <p>So my solution (that I came up with yearrrrs ago...) was</p>
  
  <pre><code>&lt;form name="callback_loadCalendar"&gt;
  &lt;form name="callback_loadNames"&gt;
  </code></pre>
  
  <p>Etc.</p>
  
  <p>And this horrible bit of JS (attached to onchange events etc) to then call the relevant function:</p>
  
  <pre><code>if (f.getAttribute('name') &amp;&amp; f.getAttribute('name').indexOf('callback') === 0)
      eval(f.getAttribute('name').substr(9)+'()');
  </code></pre>
  
  <p>E.g. that would call <code>loadCalendar()</code> and <code>loadNames()</code> respectively.</p>
  
  <p>What SHOULD I be doing instead?</p>
  
  <p>Thanks!</p>