<body>
<script>
window.addEventListener('DOMContentLoaded', init);
function init() {
var
a = document.querySelectorAll('button[type="button"]'),
b = document.getElementById('result'),
i;
for (i = 0; i < a.length; i++) {
a[i].addEventListener('click', function() {
b.innerText = +this.innerText + +b.innerText;
});
}
}
</script>
<form>
<button type="button">0</button>
<button type="button">1</button>
<button type="button">2</button>
<button type="button">3</button>
<button type="button">4</button>
<button type="button">5</button>
<button type="button">6</button>
<button type="button">7</button>
<button type="button">8</button>
<button type="button">9</button>
</form>
<div id="result"></div>
</body>