javascript onkeypressed not giving current text box content
        Posted  
        
            by 
                Austin
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Austin
        
        
        
        Published on 2010-12-26T01:38:59Z
        Indexed on 
            2010/12/26
            1:54 UTC
        
        
        Read the original article
        Hit count: 643
        
JavaScript
|onkeypress
I have an html form like this:
<form id="boxy" action="layout.html" method="get" accept-charset="utf-8">
  <input type="text" id="a" onkeypress="Boxy.Check(this);">
</form>
Invoking javascript like this:
Boxy.Check = function() {
    input = document.getElementById(this.currentSelector.id).value;
    console.log("\"" + input + "\"");
};
However, this.value is the previous value before onkeypress.
For example, if I just type "A" into the form, console.log() prints "". And if I type "AA", console.log prints "A".
Is there a way to get the current content of the input?
© Stack Overflow or respective owner