 <p>you have to update your html code little bit as follows to store clicked number button's value into textbox. Here, I stored that value in both textboxes. I replaced code little bit of textbox, number's button and added one javascript function instead all code is as it is. Please, give one look.</p> <p>Textboxes: </p> <pre><code>&lt;tr&gt; &lt;td width="292" align="center" height="23"&gt; &lt;input type="text" name="num1" id="num1" value="" size="10"&gt; &lt;input type="text" name="num2" id="num2" value="" size="10"&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Buttons:</p> <pre><code>&lt;input type="button" onclick="storeNumber(this)" value="1" name="1"&gt; &lt;input type="button" onclick="storeNumber(this)" value="2" name="2"&gt; &lt;input type="button" onclick="storeNumber(this)" value="3" name="3"&gt;&lt;br&gt; &lt;input type="button" onclick="storeNumber(this)" value="4" name="4"&gt; &lt;input type="button" onclick="storeNumber(this)" value="5" name="5"&gt; &lt;input type="button" onclick="storeNumber(this)" value="6" name="6"&gt;&lt;br&gt; &lt;input type="button" onclick="storeNumber(this)" value="7" name="7"&gt; &lt;input type="button" onclick="storeNumber(this)" value="8" name="8"&gt; &lt;input type="button" onclick="storeNumber(this)" value="9" name="9"&gt; &lt;input type="button" onclick="storeNumber(this)" value="0" name="0"&gt; </code></pre> <p>Call Javascript function in head tag </p> <pre><code>&lt;script language='javascript'&gt; function storeNumber( obj ) { var previousVal = document.getElementById("num1").value; previousVal = previousVal + obj.value; document.getElementById("num1").value = previousVal; document.getElementById("num2").value = previousVal; } &lt;/script&gt; </code></pre> <p>Thanks.</p>