Why does a RETURN end up in my textarea after clearing it?

D

Doug Lerner

(Using Prototype library)

I am checking for a keypress event, which triggers this handler:

function txKeyPressHandler(theEvent) {
var key = theEvent.which || theEvent.keyCode;

switch (key) {
case Event.KEY_RETURN:
txIMSendMsg();
break;
}
}

inside txIMSendMsg() I do:

var msg = $F('msg');
Field.clear($('msg'));

In other words, after saving the value of the field I clear it out.

Then when I'm all done with what I am doing I do:

Field.focus($('msg'));

The first time I enter the window the "msg" textarea is empty and the cursor
is at the beginning of the field. But after I enter text and press RETURN
the next time the focus returns to the 2nd line of the text area, like the
RETURN I entered to trigger the event remains in the msg textarea, even
though it was cleared.

Any idea why and how to avoid this?

Thanks!

doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top