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. Link to comment https://forums.phpfreaks.com/topic/134701-incremental-form-box/ 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> Link to comment https://forums.phpfreaks.com/topic/134701-incremental-form-box/#findComment-701607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.