I have this following code: JS Fiddle
<html>
<head>
<script>
function increase(){
var a = 1;
var textBox = document.getElementById("text");
textBox.value = a;
a++;
}
</script>
</head>
<body>
<button type="button" onclick="increase()">show</button>
<input type="text" id="text">
</body>
</html>
What I am trying to do is:
- On clicking the button the value of 'a' will be displayed in the textbox and 'a' will be incremented.
- On clicking again now the incremented value should be displayed but this doesn't happen.
Where am I going wrong?