GuitarGod Posted September 10, 2010 Share Posted September 10, 2010 Hi all, I'm having a little problem with JS's "this.value" - it always seems to be one letter behind than the fields actual value. If I may explain: <input type="text" onkeydown="alert(this.value)"> As you can see, everytime a key is entered, the value of the text box should be displayed in a Javascript alert. However, if I entered the letter "M", then a blank JS alert would pop up. If I enter another letter along side the "M", for example "D", then the letter "M" would alert, but not the "D". If I entered a third letter, then the letters "MD" would alert, but not the third letter. So the alert message is always one letter behind. I hope you can understand what I mean. Is there anyway round this so the exact value that I enter is the value that gets alerted? Thanks for any light you can shed on this. Link to comment https://forums.phpfreaks.com/topic/213064-thisvalue-one-letter-behind/ Share on other sites More sharing options...
Adam Posted September 10, 2010 Share Posted September 10, 2010 Try 'onkeyup'. Link to comment https://forums.phpfreaks.com/topic/213064-thisvalue-one-letter-behind/#findComment-1109655 Share on other sites More sharing options...
GuitarGod Posted September 10, 2010 Author Share Posted September 10, 2010 Works! Thank you very much! Link to comment https://forums.phpfreaks.com/topic/213064-thisvalue-one-letter-behind/#findComment-1109781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.