visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Java :: Using onKeyPress/onChange/onBlur on textarea


By: TheFalklands U.S.A.  Date: 23/05/2003 00:00:00  English  Points: 300 Status: Answered
Quality : Excellent
If use typed comma or semi-colon, or changes
focus to a different form element, test function will be called. And
below is my code:

<script language="Javascript">
function test(myObject, flag)
{
if ( (flag) || ((event.keyCode == 59) || (event.which == 59)) || ((event.keyCode == 44) || (event.which == 44)))
{alert(myObject.value);}
}
function closeWin()
{self.close();}
</script>
...
<form name='test'>
<textarea
name='textareaName' cols='44' rows='3' onChange='test(this, true);'
onKeyPress='test(this);' onBlur='test(this, true);'
></textarea>
<input type='text' name='textName'>
<input type='button' name='buttonName' onclick='closeWin();' value='Cancel'>
</form>
...

I
have a problem: when input value(e.g: test;) into textareaName field,
the test function is always run more one time. Please show me the way
can run this only one time.

Thanks in advance,
By: VGR Date: 23/05/2003 20:55:00 English  Type : Comment
why don't you just use OnChange ?
the other events are conditionned by that one
it's normal you get multiple calls, as you've multiple events

By: TheFalklands Date: 23/05/2003 21:35:00 English  Type : Comment
Hi VGR

Thank for your reply.
But i'm still get stuck with this.
Actualy i want this function is called when user types comma or semi-colon, or changes value/focus to a different form element.
If just use onChange event how can it get this function when user types comma or semi-colon.
Please explain more detail for this.

Thanks in advance,
By: VGR Date: 23/05/2003 23:17:00 English  Type : Answer
OnChange is triggered as soon as the value in the control changes, AFAIK

So typing ; , or whatever except TAB will trigger it, I think.

Do register to be able to answer

EContact
browser fav
page generated in 95.427990 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page