Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    30sec countdown, help.

    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.

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Code:
    <!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>
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by h4lfl1ng; 12-29-2005 at 09:47 AM.

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    you may use a cookie
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Wait is this possible with classes?
    PHP Code:
    function hideLink(){
    var 
    ele document.getElementsByTagName('*');
    for(var 
    i=0;i<ele.length;i++){
    ele[i].style.display=(ele[i].className=='myclass')?'none':'';
    }

    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found another way via google

    PHP Code:

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



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •