TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 12-09-2007, 05:05 PM   #1 (permalink)
The Acquainted
Inquisitive 
 
WinSrev's Avatar
 
Join Date: Sep 2007
Posts: 133
Thanks: 6
WinSrev is on a distinguished road
Application Error Magic Div's

Hey,

I wanted to try and make it so that, if someone clicked a link then it'd wait 3 seconds then make a certain div disappear.

I have this code:
Code:
function hideElement(obj){
    document.getElementById(obj).style.display = "none";
}
And this on the link itself (in an on click):
Code:
window.setTimeout(hideElement(admin2), 3000);
But it just produces an error, as in it does nothing.
Any ideas?
Thanks.
Send a message via ICQ to WinSrev
WinSrev is offline  
Reply With Quote
Old 12-09-2007, 05:08 PM   #2 (permalink)
The Wanderer
Newcomer 
 
Join Date: Dec 2007
Posts: 13
Thanks: 2
devolio is on a distinguished road
Default

Try setting your window.setTimeout to a var, but I'm curious, what's the error it's giving you?

Also, you may want to just setTimeout, not window.setTimeout.
devolio is offline  
Reply With Quote
Old 12-09-2007, 05:09 PM   #3 (permalink)
The Acquainted
Inquisitive 
 
WinSrev's Avatar
 
Join Date: Sep 2007
Posts: 133
Thanks: 6
WinSrev is on a distinguished road
Default

Well, internet explorer gives the error of
Quote:
Originally Posted by IE
Object Required
Send a message via ICQ to WinSrev
WinSrev is offline  
Reply With Quote
Old 12-09-2007, 05:09 PM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,541
Thanks: 72
Wildhoney is on a distinguished road
Default

javascript Code:
function hideElement(obj){
    document.getElementById(obj).style.display = "none";
}

setTimeout("hideElement('admin2')", 3000);
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-09-2007, 05:11 PM   #5 (permalink)
The Wanderer
Newcomer 
 
Join Date: Dec 2007
Posts: 13
Thanks: 2
devolio is on a distinguished road
Default

Gah, I thought it was missing quotes too. Shows how much JS I've done lately.
devolio is offline  
Reply With Quote
Old 12-09-2007, 05:12 PM   #6 (permalink)
The Acquainted
Inquisitive 
 
WinSrev's Avatar
 
Join Date: Sep 2007
Posts: 133
Thanks: 6
WinSrev is on a distinguished road
Default

That gives a syntax error. It works without the " but it happens instantly.
Send a message via ICQ to WinSrev
WinSrev is offline  
Reply With Quote
Old 12-09-2007, 05:15 PM   #7 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 700
Thanks: 2
Salathe is on a distinguished road
Default

JavaScript Code:
setTimeout(function(){ hideElement('admin2'); }, 3000);
__________________
Salathe is online now  
Reply With Quote
Old 12-09-2007, 05:15 PM   #8 (permalink)
The Wanderer
Newcomer 
 
Join Date: Dec 2007
Posts: 13
Thanks: 2
devolio is on a distinguished road
Default

Nevermind, I wasn't doing it right and Salathe beat me to it.

Edit: Just in case...

javascript Code:
function hideElement(obj){
    document.getElementById(obj).style.display = "none";
}
function clickTest(){
    window.setTimeout(hideElement('test'), 3000);
}

Last edited by devolio : 12-09-2007 at 05:49 PM.
devolio is offline  
Reply With Quote
Old 12-09-2007, 05:20 PM   #9 (permalink)
The Acquainted
Inquisitive 
 
WinSrev's Avatar
 
Join Date: Sep 2007
Posts: 133
Thanks: 6
WinSrev is on a distinguished road
Default

Thanks a lot, it works great :D
Send a message via ICQ to WinSrev
WinSrev is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:37 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0