chao Posted November 29, 2008 Share Posted November 29, 2008 I would like to make a form box like such: Count: 5 | + | | - | Submit The | + | button would increment the integer. | - | would decrement the integer. How could it be done? PS: This might require JavaScript. I'll repost it in another forum section if needed. Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 29, 2008 Share Posted November 29, 2008 <html> <head> <script type="text/javascript"> function addValue(fieldID, addAmount) { var fieldObj = document.getElementById(fieldID); var newValue = (parseInt(fieldObj.value) + addAmount); fieldObj.value = (newValue<0) ? 0 : newValue; return; } </script> </head> <body> Count: <input type="text" name="count" id="count" readonly="readonly" value="5" /> <button onclick="addValue('count', 1)">+1</button> <button onclick="addValue('count', -1)">-1</button> <br /><br /> <button type="submit">Submit</button> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.