Hide div after few seconds

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
GinsBabu
Forum Newbie
Posts: 8
Joined: Sat Oct 24, 2009 7:00 am

Hide div after few seconds

Post by GinsBabu »

Hi,
In my form i have a button which calls a js function to do some action.After the action a message shows.I want to know how can i hide the div if the message has been shown for 10 second.Any help?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Hide div after few seconds

Post by Christopher »

Use one of the Javascript timer functions (setTimeout(), clearTimeout(), setInterval() and clearInterval() ). They will call a function after a specified amount of time. Set it for 10 seconds and have the function you pass to it hide the div.
(#10850)
GinsBabu
Forum Newbie
Posts: 8
Joined: Sat Oct 24, 2009 7:00 am

Re: Hide div after few seconds

Post by GinsBabu »

Hi..

Thanks arborint ....i was working on that but still its not working...my code was
have a div tag like this..
<div id="d" style="display:inline">
<?php echo $this->message;?>
</div>

and the js
function sendStatusReport(){
document.listclientchoosen.action = "<?php echo $this->baseUrl;?>/admin/clientexports/report";
document.listclientchoosen.submit();
setTimeout("toggle()", 8000 );
}

function toggle() {
var ele = document.getElementById("d");
ele.style.display = "none";
}
Wat am i doing wrong....??also the action performing inside the sendstatusreport() is mail sending.So it amy took 8s or 10 s or 15 s.How can excatly point out the time.
Post Reply