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.
Since you gave me nothing to start on, here is a simple example.
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>