Languages :: Java :: Using onKeyPress/onChange/onBlur on textarea |
|||
| By: TheFalklands |
Date: 23/05/2003 00:00:00 |
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 | 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 | 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 | 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 |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








