Increment and Decrement Counter on Button Click in Javascript code example
Example: javascript increment counter onclick
// Example implementation:
function incrementValue()
{
var value = parseInt(document.getElementById('number').value, 10);
value = isNaN(value) ? 0 : value;
value++;
document.getElementById('number').value = value;
}
/* Example Html:
<form>
<input type="text" id="number" value="0"/>
<input type="button" onclick="incrementValue()" value="Increment Value" />
</form>
*/