function min(a, b) { if (a > b) { return a } return b } function increase(id) { input = document.getElementById(id) input.value= min(parseInt(input.value)+1, 0) } function decrease(id) { input = document.getElementById(id) input.value= min(parseInt(input.value)-1, 0) }