473,597 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ 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 1046
You can use a global timer variable.

var tim;
function onKeyDown()
{
if (tim != null)
clearTimeout(ti m);
tim = setTimeout('Tim erUp()', 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*****@discus sions.microsoft .comwrote in message
news:1A******** *************** ***********@mic rosoft.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
8267
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8258
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6681
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5844
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5423
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3880
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3921
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2394
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.