My problem is that I have a form in my HTML that I write to the database after filling it out.
The form consists of 7 labels with 7 input fields type=’number’
It all works so far, but it annoys me because it is designed for mobile phones that I have to keep clicking on the field and entering the number.
Now I have come up with a system that I can use between the input fields type=’text’,
I have one button each for increase and decrease. I intercept this with a JavaScript and let the will be manipulated to correspond.
This only worked to a limited extent. If I comment out the “Form Tag” it works. But as soon as I comment on the “form tag” again, nothing works anymore.
Now the question is. Where is the mistake or why it no longer works in this form?
HTML excerpt:
<form action="" method="post">
<label>Test1</label><br>
<input type="button" onclick="dec('number')" id="dec" value="-"/>
<input type="text" name="test1" id="number" value="0" min="0" size="3" />
<input type="button" onclick="inc('number')" id="inc" value="+" />
</form>
JS excerpt:
function inc(number) {
document.getElementById("number").value++;
}
function dec(number) {
if (document.getElementById("number").value != 0)
document.getElementById("number").value--;
}