In its most basic incarnation..
JavaScript:
<script>
var i = 0;
function buttonClick() {
document.getElementById('inc').value = ++i;
}
</script>
Markup:
<button onclick="buttonClick()">Click Me</button>
<input type="text" id="inc" value="0"></input>