473,473 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

javascript help please

hey all,
i have a key up javascript function where i want half the function to run
and then wait about 2 seconds, but if within that 2 seconds another key up
event has a occurred, i need it to cancel the initial call to the function.

can someone please show me if this can be done.

thanks,
rodchar
Mar 26 '08 #1
2 1040
You can use a global timer variable.

var tim;
function onKeyDown()
{
if (tim != null)
clearTimeout(tim);
tim = setTimeout('TimerUp()', 2000);
//do key work here
}
function TimerUp()
{
//do timer work here
}
Mar 26 '08 #2
You have an answer, but I suggest you consider the problem domain before
solving in this manner. Most likely, you are either a) wanting to allow for
corrections or b) wanting to wait until the entire string is entered before
processing.

If a, your method might be the best, depending on what you are doing. If b,
you can process the portion that fits the keystroke and then capture the
blur event for the control to do complete processing. This will help you
avoid the wait two seconds.

I know nothing of your app, but I did a heavy JavaScript app years ago for
key entry (replace a windows app). If I would have waited two seconds, I
would have been hosed. Your app is, hopefully, completely different.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:1A**********************************@microsof t.com...
hey all,
i have a key up javascript function where i want half the function to run
and then wait about 2 seconds, but if within that 2 seconds another key up
event has a occurred, i need it to cancel the initial call to the
function.

can someone please show me if this can be done.

thanks,
rodchar

Mar 26 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.