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 6 of 6

Thread: Timed button

  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Timed button

    I need an timed button. When you come to site, you must wait in that site ?? seconds and then button comes pressable.

  • #2
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,376
    Thanks
    263
    Thanked 32 Times in 31 Posts
    never done a timed button before but i have done a timeout on a page, so you could play with this and take them to a page initially without the button then when they timeout it takes them to the page with the button... just a dif way of doing it.. here is the code to timeout a page

    Code:
    <script> 
    <!-- 
    //change below target URL to your own 
    var targetURL="whatever.php" 
    //change the second to start counting down from 
    var countdownfrom=30 
    
    var currentsecond=document.redirect.redirect2.value=countdownfrom+1 
    function countredirect(){ 
    if (currentsecond!=1){ 
    currentsecond-=1 
    document.redirect.redirect2.value=currentsecond 
    } 
    else{ 
    window.location=targetURL 
    return 
    } 
    setTimeout("countredirect()",1000) 
    } 
    
    countredirect() 
    //--> 
    </script>

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by durangod View Post
    never done a timed button before but i have done a timeout on a page, so you could play with this and take them to a page initially without the button then when they timeout it takes them to the page with the button... just a dif way of doing it.. here is the code to timeout a page

    Code:
    <script> 
    <!-- 
    //change below target URL to your own 
    var targetURL="whatever.php" 
    //change the second to start counting down from 
    var countdownfrom=30 
    
    var currentsecond=document.redirect.redirect2.value=countdownfrom+1 
    function countredirect(){ 
    if (currentsecond!=1){ 
    currentsecond-=1 
    document.redirect.redirect2.value=currentsecond 
    } 
    else{ 
    window.location=targetURL 
    return 
    } 
    setTimeout("countredirect()",1000) 
    } 
    
    countredirect() 
    //--> 
    </script>
    Eh, don't know what do remove / add. Please, just code for that?

  • #4
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,376
    Thanks
    263
    Thanked 32 Times in 31 Posts
    ok if you want to take them to a waiting page and have that page timeout then take them to a page with the button it will be like this

    im assuming this is in a php file if not let me know.


    first place this at the bottom of your php file after the ?>

    change the target URL to the page that you want them to go to after they wait. and change the countdownfrom to how long you want them to wait, its set now at 30 sec.. it will countdown from 30 sec then take them to the page you want..

    Code:
    <script> 
    <!-- 
    //change below target URL to your own 
    var targetURL="yourpage.php"
    //change the second to start counting down from 
    var countdownfrom=30 
    
    var currentsecond=document.redirect.redirect2.value=countdownfrom+1 
    function countredirect(){ 
    if (currentsecond!=1){ 
    currentsecond-=1 
    document.redirect.redirect2.value=currentsecond 
    } 
    else{ 
    window.location=targetURL 
    return 
    } 
    setTimeout("countredirect()",1000) 
    } 
    
    countredirect() 
    //--> 
    </script>

    now display the counter on your page so they can see it. again this is written for a php file..

    you can post this code below whereever you want to display the timer..

    Code:
    echo "<form name='redirect'><center> 
    <font face='Arial'><b>You will be redirected to a different page in<br /><br /> <form> 
    <input type='text' size='3' name='redirect2' /></form>
    seconds</b></font></center>";

    does that help you

  • #5
    New Coder
    Join Date
    Mar 2010
    Location
    New Jersey USA
    Posts
    81
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Something like this?

    Code:
    <html>
    <head>
    <script type="text/javascript">
    
    window.onload=function(){
    
    setTimeout(enableIt,5000)
    
    }
    
    function enableIt(){
    
    document.getElementById('send').disabled=false;
    
    }
    
    </script>
    </head>
    <body>
    
    <input id="send" type="submit" disabled="disabled" name="send" value="submit"/> 
    </body>
    </html>
    Last edited by connollyc4; 11-22-2010 at 02:00 PM.

  • Users who have thanked connollyc4 for this post:

    Varmistuskoodi (11-22-2010)

  • #6
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by connollyc4 View Post
    Something like this?

    Code:
    <html>
    <head>
    <script type="text/javascript">
    
    window.onload=function(){
    
    setTimeout(enableIt,5000)
    
    }
    
    function enableIt(){
    
    document.getElementById('send').disabled=false;
    
    }
    
    </script>
    </head>
    <body>
    
    <input id="send" type="submit" disabled="disabled" name="send" value="submit"/> 
    </body>
    </html>
    *Thanks this user*
    Thank you! Just what I did need!


  •  

    Posting Permissions

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