title: this parameter not passing expected element
body: <p>I have a dynamic set of input fields being generated.  They all get named sequentially and each has an onFocus() handler. Just before each Input element is a div with a corresponding Id where I grab a dollar value from.</p>
  
  <pre><code>&lt;input type="hidden" name="balance" value="2500.0" /&gt;  
  &lt;div id="invoiceAmount0"&gt;$500.00&lt;/div&gt;
  &lt;input type="text" size="8" id="invoiceBalance0" name="invoiceBalance0" value="" onfocus="setBalance(this)" /&gt;
  &lt;div id="invoiceAmount1"&gt;$500.00&lt;/div&gt;
  &lt;input type="text" size="8" id="invoiceBalance1" name="invoiceBalance1" value="" onfocus="setBalance(this)" /&gt;
  &lt;div id="invoiceAmount2"&gt;$500.00&lt;/div&gt;
  &lt;input type="text" size="8" id="invoiceBalance2" name="invoiceBalance2" value="" onfocus="setBalance(this)" /&gt;
  </code></pre>
  
  <p>The JS onFocus handler is as follows:</p>
  
  <pre><code>function setBalance(e) //e should be an input field element
  {
    var balance = document.PaymentForm.balance.value;
    var remainder = balance;
  
    var index = 0;
    var paymentField = document.getElementById('invoiceBalance'+index);  //get the first input payment element
    while (paymentField != null &amp;&amp; paymentField != e) //start with the first field and calculate the remaining balance
    {
      var paymentApplied = paymentField.value.replace(/[^0-9\.]+/g,""); 
      remainder = remainder - paymentApplied;
      index++;
      paymentField = document.getElementById('invoiceBalance'+index);  
    }
    while (e == paymentField)  //set the selected elements value
    {
      var invoiceBalance = document.getElementById('in'+index).innerHTML.replace(/[^0-9\.]+/g,"");
      if (parseFloat(remainder) &gt; parseFloat(invoiceBalance))
        e.value = parseFloat(invoiceBalance).toFixed(2).toLocaleString();    
      else
        e.value = parseFloat(remainder).toFixed(2).toLocaleString();
      index++;
      paymentField = document.getElementById('invoiceBalance'+index); 
    }
    while (paymentField != null)  //blank out the rest of the input fields
    { 
      paymentField.value = ''; 
      index++;
      paymentField = document.getElementById('invoiceBalance'+index); 
    }
    e.select();
  }
  </code></pre>
  
  <p>The concept here is to calculate the remaining balance and set the input field's value as the user focuses the fields.</p>
  
  <p>The problem is that The "this" parameter is always set to the first Input element "invoiceBalance0".  I'm expecting it to be set to the element referring to it in it's onFocus handler.</p>
  
  <p>What am I not seeing?</p>