<input type="text" id="a1" value="1"> +
<input type="text" id="a2" value="1"> =
<input type="text" id="a3" readonly="true">
<br>
<input type="button" value="click" onclick="foo()">
<script>
function foo(){
a3.value = parseInt(a1.value) + parseInt(a2.value);
}
</script>
<input type="text" id="a2" value="1"> =
<input type="text" id="a3" readonly="true">
<br>
<input type="button" value="click" onclick="foo()">
<script>
function foo(){
a3.value = parseInt(a1.value) + parseInt(a2.value);
}
</script>