h4lfl1ng
12-29-2005, 05: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.
missing-score
12-29-2005, 05: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.
_Aerospace_Eng_
12-29-2005, 07:42 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function hideLink(){
document.getElementById('thelink').style.display='none';
}
setTimeout("hideLink()",30000);
//-->
</script>
</head>
<body>
<a href="#" id="thelink">You have 30 seconds to use this link</a>
</body>
</html>
h4lfl1ng
12-29-2005, 08: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.
EDIT:
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.
Wait is this possible with classes?
function hideLink(){
var ele = document.getElementsByTagName('*');
for(var i=0;i<ele.length;i++){
ele[i].style.display=(ele[i].className=='myclass')?'none':'';
}
}
h4lfl1ng
12-29-2005, 09: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)
temparray[inc++]=rootobj[i]
}
return temparray
}