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! Quote Link to comment 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> Quote Link to comment Share on other sites More sharing options...
Jason28 Posted June 10, 2008 Author Share Posted June 10, 2008 Thanks works perfectly 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.