Since you're setting the value of upd to a function containing the setTimeout, you should be able to just
delete upd; -----Original Message----- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Sean O Sent: Wednesday, October 10, 2007 10:39 AM To: jquery-en@googlegroups.com Subject: [jQuery] How to clear setTimeout? Hi, I'm trying to implement an autoSave function on my web application. Something that automatically saves the contents of the current field 6 seconds after the last keyUp. It works, but I can't clear the multiple setTimeouts triggered on each keyUp event. Example: $("input").keyup(function(){ var self = this; var upd = setTimeout( function() { updateField( $(self) ); // function outside $ scope to update field contents in dB },6000); }); I must've tried about 27 permutations of clearTimeout, setting flag variables, nullifying variables, etc. Nothing has worked. To be clear, I need to "restart the countdown" to update the field if a user presses another key within 6 seconds of the previous letter. I'd rather not be shooting off POSTs on every keystroke ;) (BTW, I've used the onChange event before, but for text inputs, the user has to manually tab/click out of the field to trigger that event) Thanks, _________ SEAN O http://www.sean-o.com -- View this message in context: http://www.nabble.com/How-to-clear-setTimeout--tf4601640s27240.html#a1313843 2 Sent from the jQuery General Discussion mailing list archive at Nabble.com.