With javascript, how can I do it so when i click a form button it adds 1 to a number? The number it increments could be in a form text field or something.
Obviously it'd be on onclick but I'm not sure of the code.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With