haolan Posted August 8, 2007 Share Posted August 8, 2007 Hi phpfreaks.. I am trying to create a function to remove one number from a textbox, just like a backspace button. I have made the following code: function backspace() { display = document.post_form.post_display.value; disp_length = display.length; newString = display.substring(0, disp_length - 1); document.post_form.post_display.value = newString.ToString(); } My form is named post_form and the textbox is named post_display. This code does not work.. What is wrong? Quote Link to comment Share on other sites More sharing options...
emehrkay Posted August 8, 2007 Share Posted August 8, 2007 i always say it is easier/more accurate to reference an element by id document.getElementById('eleid').value = whatever; first alert newString and see if it is doing what you want. then use the reference by id technique Quote Link to comment Share on other sites More sharing options...
mainewoods Posted August 9, 2007 Share Posted August 9, 2007 change to 'minus 2' newString = display.substring(0, disp_length - 2); 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.