Jason28 Posted June 10, 2008 Share Posted June 10, 2008 Hello, can anyone provide me with a working code that allows me to click a button to add +1 to the current field? So if a field has the number 12, I can click on a button to make it 13. Thanks! Link to comment https://forums.phpfreaks.com/topic/109580-solved-add-1-to-numeric-field/ Share on other sites More sharing options...
KevinM1 Posted June 10, 2008 Share Posted June 10, 2008 Hello, can anyone provide me with a working code that allows me to click a button to add +1 to the current field? So if a field has the number 12, I can click on a button to make it 13. Thanks! <html> <head> <title>Increment by 1</title> <script type="text/javascript"> window.onload = function() { var myButton = document.getElementById("myButton"); var myInput = document.getElementById("myInput"); myButton.onclick = function() { myInput.value = parseInt(myInput.value) + 1; } } </script> </head> <body> Add 1 to: <input id="myInput" name ="myInput" type="text"><br /> <button id="myButton" value="Add 1!"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/109580-solved-add-1-to-numeric-field/#findComment-562145 Share on other sites More sharing options...
Jason28 Posted June 10, 2008 Author Share Posted June 10, 2008 Thanks works perfectly Link to comment https://forums.phpfreaks.com/topic/109580-solved-add-1-to-numeric-field/#findComment-562202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.