...

View Full Version : Help With "clearTimeout()"



TheRoper
06-20-2004, 04:11 AM
good day -

i am trying to make a search field disappear after a certain amount of time if it is left blank. also, if the user clicks outside of the field, it disappears... you can see a mock page here (http://www.charityadvantage.com/familiesintransitionsantacruz/images/mock.htm) (look at the source also)... the problem that i'm having is that when the focus is removed from the search field, it should clear the timeOut that is set (so if the user clicks on search again to bring the field up, the timeOut is restarted)... i hope that makes sense :confused:

any help is greatly appreciated...
note: currently only works in IE... i think...

thanks!

Mr J
06-20-2004, 04:56 PM
Not sure if I fully understand your question but,

add clearTimeout('t'); to the following

function showSearch() {
clearTimeout('t');
document.all['searchtext'].style.display="none";
document.all['searchfield'].style.display="inline";
document.form.t1.focus();
t=setTimeout("hideSearch()",6000);
}

function hideSearch() {
if(document.form.t1.value==""){
document.all['searchtext'].style.display="inline";
document.all['searchfield'].style.display="none";
clearTimeout('t');
}
}

glenngv
06-21-2004, 05:55 AM
Remove the quotes around t.

clearTimeout(t);

Mr J
06-21-2004, 03:41 PM
Oops!

Now I'm really embarrassed, I see the quotes but cannot think for the life of me why I put them in



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum