Ask your own question, for FREE!
Computer Science 14 Online
Spectrum:

How do I make 0 go up by +1 every time a button is clicked using HTML and JavaScript?

Sherixn:

Here's a Stack Overflow post: https://stackoverflow.com/questions/9186346/javascript-onclick-increment-number

Spectrum:

Stack Overflow isn't really reliable-

Sherixn:

It is but okay...

Sherixn:

Here's the code: 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>

Sherixn:

from StackOverflow

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!