Javascript update/increment variable value on click
You're only incrementing a local variable that goes away at end of function. You may do this :
var a = 1;
function increase(){
var textBox = document.getElementById("text");
textBox.value = a;
a++;
}
<input type="text" id="text" value="1"/>
function increase(){
var textBox = document.getElementById("text");
textBox.value++;
}