title: Using one javascript function for multiple inputs on one form
body: <p>We have a simple age calculating script, that takes a date input (3 selects - day, month, year) and determine how old.  It is triggered by an onChange assigned to the year select.</p>
  
  <p>There are several date inputs scattered through the form, each one set up the same, other than the input names (day1 vs day 1 vs day 3, etc).</p>
  
  <p>Currently we have simply duplicated the js code and manually changed the input variables ...</p>
  
  <p><code>function Age1()<br>
  {<br>
      var oldDay = document.step1.day1.value;<br>
      var oldMonth = document.step1.month1.value;<br>
      var oldYear = document.step1.year1.value;<br>
      and more script....</code></p>
  
  <p><code>function Age2()<br>
  {<br>
      var oldDay = document.step1.day2.value;<br>
      var oldMonth = document.step1.month2.value;<br>
      var oldYear = document.step1.year2.value;<br>
      and more script....</code></p>
  
  <p>and so forth.</p>
  
  <p>Ideally we would like to reuse one script, rather than hardcoding one for each instance.  I have tried a bunch of ideas to no avail, but the ideal would be to trigger it via: <code>onChange="Age(X);"</code> and then have the js insert the proper variable:</p>
  
  <p><code>function Age(varX)<br>
  {<br>
      var oldDay = document.step1.dayX.value;<br>
      var oldMonth = document.step1.monthX.value;<br>
      var oldYear = document.step1.yearX.value;<br>
  and so on ....</code></p>
  
  <p>Any ideas for us ?  Thanks in advance</p>