View Full Version : 30sec countdown, help.

12-29-2005, 06:11 AM
Okay what im trying to accomplish is a 30second counter. When the script is initialized it echos a link, then when 30 seconds is up the link disappears. sleep(); nor set_time_limit(); work. Because they keep the browser in a loading state. Im still new to php, and im not sure if there is a specific function out there. Im looking for a push in the right direction.

12-29-2005, 06:19 AM
This can't be done in PHP.. You would need to use some kind of JavaScript code or Meta refresh to get the desired effect. I am going to move this to the JavaScript forum where I'm sure someone will be able to help you out.

12-29-2005, 08:42 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function hideLink(){

<a href="#" id="thelink">You have 30 seconds to use this link</a>

12-29-2005, 09:33 AM
wow, that is simple. I knew i should of learned javascript a long time ago.

Wait is this possible with classes? Because this javascript is used repeated times for entries taken out of a mysql db. And with id's only the first entries link disappears.

like getElementByClass, I tried it but nothing happened.

I just realized that this wont work too well. Because everytime you refresh the page itl have the link visible. It has to be a one time thing after the entry is created and displayed. Maybe ill have to store a boolean in the mysql for every entry, and after 30 sec with the js it switches to false as in not deletable or something.

12-29-2005, 09:54 AM
you may use a cookie

12-29-2005, 09:58 AM
Wait is this possible with classes?

function hideLink(){
var ele = document.getElementsByTagName('*');
for(var i=0;i<ele.length;i++){

12-29-2005, 10:31 AM
I found another way via google

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
return temparray