How to write this function correctly
<p>I asked this question a bit earlier and have only been able to gain a little ground. What I have is still not working as expected.</p>

<p>What I want to do is to share a number pad with 3 different forms. If the user clicks on box 'a', all of the numbers (from the anchor tag) as well as the focus should go into that input box. If the user clicks on box 'b', then all of the numbers (from the anchor tag) as well as the focus should go into that input box.</p>

<p>Can someone help me to get this correct?</p>

<pre><code>function box(box) {
  if(box == 'a') {
    document.getElementById("a").focus();
    document.getElementById('a').value += '1';
    document.getElementById('a').value += '2';
  }else if(box == 'b') {
    document.getElementById("b").focus();
    document.getElementById('b').value += '1';
    document.getElementById('b').value += '2';
  }
}

function process(val){
  document.getElementById('a').value += val;
}
</code></pre>

<hr>

<p>When the user clickes one of these anchor tags, I am expecting the value to be populated into the proper input box. The input box is <strong>first determined</strong> when the user clicks the anchor tag that sets the focus into the box they want to use.</p>

<p>STEP 1 Choose the input box to use and put focus: </p>

<pre><code>&lt;a href="#" onclick="box('a')"&gt;a&lt;/a&gt;&lt;br /&gt;
&lt;a href="#" onclick="box('b')"&gt;b&lt;/a&gt;&lt;br /&gt;
</code></pre>

<p>STEP 2 Put the data into the box:</p>

<pre><code>&lt;a href="#" onclick="process('4');"&gt;4&lt;/a&gt;
&lt;a href="#" onclick="process('5');"&gt;5&lt;/a&gt;


&lt;form name="a"&gt;
  &lt;input type="text" id="a" /&gt;
&lt;/form&gt;
&lt;form name="b"&gt;
  &lt;input type="text" id="b" /&gt;
&lt;/form&gt;
</code></pre>
