0

How to add zero to hidden input?

I want to add zero to a hidden input field when '0' button is pressed. This is html: <form method="POST"> <input type="hidden" id="code" name="code" > </form> And the button: <button onclick="document.getElementById('code').value+='0';" class="keypad">0</button> But when i press 0 button, hidden value doesn't change.

17th Mar 2020, 10:04 AM
ΛM!N
ΛM!N - avatar
1 Answer
+ 2
Try to log `code.value` in Javascript console, I don't see a reason why `code.value` doesn't change. Here I added logging for `code.value` in the button's 'onclick' attribute. Try and see if it works on your side. <button onclick="code.value += '0'; console.log(code.value);" class="keypad">0</button>
17th Mar 2020, 11:43 AM
Ipang