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

Thread: any ideas?

  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Location
    england
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    any ideas?

    Would it be possible to incorporate a “counter” that changes every 2 seconds i.e. “X” promotional brochures circulated so far this year? This year “X” would be 1 brochure per 2 seconds (30 per minute) i.e. by end of January 31st value of “X” would be 31x24x60x30=1,339,200. At end of 2007 = 365x24x60x30=15,768,000.

    I need it so that it will continue to count when viewed by different users( like a web counter)

    Many thanks

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    <html>
    <head>
    <script type="text/javascript">
    var fromDate = new Date(new Date().getFullYear(), 0, 1);
    function setCtr(){
       var toDate = new Date();
       var diff = (toDate - fromDate)/1000; //sec
       document.getElementById("ctr").innerHTML = Math.round(diff/2);
    }
    </script>
    </head>
    <body onload="setInterval('setCtr()', 2000);">
    <div>Number of promotional brochures circulated so far this year: <span id="ctr"></span></div>
    </body>
    </html>
    If you want to put commas to the number, you can search for such kind of script here in CF, try looking in the Post a Javascript forum.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Location
    england
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Glenn.
    Many thanks for the coding, just have a few questions though.
    Can I just cut and paste this in or do I have to add any dates in to it?
    Could I start it running from 4th of Feb and add the starting amount to it?

    Many thanks
    Keith

  • #4
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    to start from 7am

    var fromDate = Date.parse("Feb 4, 2007, 07:00:00")
    --
    var diff = (toDate.getTime() - fromDate)/1000; //sec
    --
    document.getElementById("ctr").innerHTML = Math.round(diff/2)+ how many already done before Feb4
    Last edited by tonyp12; 02-02-2007 at 07:26 PM.

  • #5
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To get two: , to show thousands & millions.
    (any count before feb4 should be added after '/2000 + number' )

    var fromDate = Date.parse("Feb 4, 2007, 07:00:00");
    function setCtr(){
    var toDate = new Date();
    var mycount = Math.round((toDate.getTime() - fromDate)/2000).toString();
    var mylen = mycount.length;
    if (mylen>3){mycount= mycount.slice(0,mylen-3) + "," + mycount.slice(mylen-3)}
    if (mylen>6){mycount= mycount.slice(0,mylen-6) + "," + mycount.slice(mylen-6)}
    document.getElementById("ctr").innerHTML = mycount;
    }
    Last edited by tonyp12; 02-02-2007 at 11:12 PM.

  • #6
    New to the CF scene
    Join Date
    Feb 2007
    Location
    england
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Tony,
    I uploaded this to my site and it was befor the start date, but nothing happened. Have I done something wrong?

    </head>
    <body onload="setInterval('setCtr()', 2000);">
    <html>
    <head>
    <script type="text/javascript">var fromDate = Date.parse("Feb 3, 2007, 22:08:00");
    function setCtr(){
    var toDate = new Date();
    var mycount = Math.round((toDate.getTime() - fromDate)/2000
    + 1999 ).toString();
    var mylen = mycount.length;
    if (mylen>3){mycount= mycount.slice(0,mylen-3) + "," + mycount.slice(mylen-3)}
    if (mylen>6){mycount= mycount.slice(0,mylen-6) + "," + mycount.slice(mylen-6)}
    document.getElementById("ctr").innerHTML = mycount;
    }
    </script>
    </head>

  • #7
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You have two sets of <head></head> ?

    Here it's running just fine.

    <html>
    <head>
    <title>mycounter</title>
    <script type="text/javascript">

    put JS code here

    </script>
    </head>
    <body onload="setInterval('setCtr()', 2000);">

    put your html here

    </body>
    </html>

    I have edited so if production date is in the future is will only show 1,999 (that's the units that is ready as of now)
    Last edited by tonyp12; 02-04-2007 at 02:03 AM.

  • #8
    New to the CF scene
    Join Date
    Feb 2007
    Location
    england
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Tony
    This is what is pasted in.

    <html>
    <head>
    <script type="text/javascript">var fromDate = Date.parse("Feb 3, 2007, 22:08:00");
    function setCtr(){
    var toDate = new Date();
    var mycount = Math.round((toDate.getTime() - fromDate)/2000
    + 1999 ).toString();
    var mylen = mycount.length;
    if (mylen>3){mycount= mycount.slice(0,mylen-3) + "," + mycount.slice(mylen-3)}
    if (mylen>6){mycount= mycount.slice(0,mylen-6) + "," + mycount.slice(mylen-6)}
    document.getElementById("ctr").innerHTML = mycount;
    }
    </script>
    </head>
    <body onload="setInterval('setCtr()', 2000);">
    <div>Number of promotional brochures circulated so far this year: <span id="ctr"></span></div>
    </body>

  • #9
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And does it work?

    click Here
    then Right click on that webpage and select 'viewsource'

    So at 10:08pm tonight you start with 1999 units and add one every 2 second after that?
    Last edited by tonyp12; 02-04-2007 at 01:50 AM.

  • #10
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Updated version that does not show negative amount, in case the fromDate is in the future.
    1,999 is what is already done, note it twice and once with " "

    Code:
    <html>
    <head>
    <title>mycounter</title>
    <script type="text/javascript">
    
    var fromDate = Date.parse("Feb 3, 2007, 22:08:00");
    function setCtr(){
    var toDate = new Date();
    var mycount = Math.round((toDate.getTime() - fromDate)/2000)
    mycount = mycount>0 ? (mycount + 1999).toString() : "1999"
     
    var mylen = mycount.length;
    if (mylen>3){mycount= mycount.slice(0,mylen-3) + "," + mycount.slice(mylen-3)}
    if (mylen>6){mycount= mycount.slice(0,mylen-6) + "," + mycount.slice(mylen-6)}
    document.getElementById("ctr").innerHTML = mycount;
    }
    
    
    </script>
    </head>
    <body onload="setInterval('setCtr()', 2000);">
    
    <div>Number of promotional brochures circulated so far: <span id="ctr"></span></div>
    
    </body>
    </html>
    Last edited by tonyp12; 02-04-2007 at 02:07 AM.

  • #11
    New to the CF scene
    Join Date
    Feb 2007
    Location
    england
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi tony,
    Tried it by adding into my homepage and uploading it. Still did not work. Click here to have a look.
    set it for 4.30pm today
    Many thanks
    Keith

  • #12
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can not simple use cookie cutter to paste any example from this board.
    You have to merge the 3 important part to your specific website.


    You arlready have <script></script>
    Put the JS code in between


    Code:
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
     
    var fromDate = Date.parse("Feb 4, 2007, 16:30:00");
    function setCtr(){
    var toDate = new Date();
    var mycount = Math.round((toDate.getTime() - fromDate)/2000)
    mycount = mycount>0 ? (mycount + 1999).toString() : "1999"
     
    var mylen = mycount.length;
    if (mylen>3){mycount= mycount.slice(0,mylen-3) + "," + mycount.slice(mylen-3)}
    if (mylen>6){mycount= mycount.slice(0,mylen-6) + "," + mycount.slice(mylen-6)}
    document.getElementById("ctr").innerHTML = mycount;
    }
     
    //-->
    </script>
    </head>
    <body leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 onLoad="MM_preloadImages('images/about_us_03.jpg','images/system_03.jpg','images/modules_03.jpg.jpg','images/demo_03.jpg','images/services_03.jpg','images/partner_03.jpg','images/contacts_03.jpg')">
    <div align="center">

    And DELETE all this, leave what is in red text.
    Code:
    <html>
                <html>
    </body>
    </html></body>
    </html></html><html><body><p>
    &nbsp;<html>
    <head>
    <title>mycounter</title>
    <script type="text/javascript">
     
    var fromDate = Date.parse("Feb 4, 2007, 16:30:00");
    function setCtr(){
    var toDate = new Date();
    var mycount = Math.round((toDate.getTime() - fromDate)/2000)
    mycount = mycount>0 ? (mycount + 1999).toString() : "1999"
     
    var mylen = mycount.length;
    if (mylen>3){mycount= mycount.slice(0,mylen-3) + "," + mycount.slice(mylen-3)}
    if (mylen>6){mycount= mycount.slice(0,mylen-6) + "," + mycount.slice(mylen-6)}
    document.getElementById("ctr").innerHTML = mycount;
    }
     
     
    </script>
    </head>
    <body onload="setInterval('setCtr()', 2000);">
     
    <div>Number of promotional 
       <br>brochures circulated so far: <span id="ctr"></span></div>
    </body>
    </html></p> 
    </body>
    </html>
    Add the red text to your onLoad.
    <body leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 onLoad="setInterval('setCtr()', 2000); MM_preloadImages('images/about_us_03.jpg',...............

    This is the edited version of your website:
    BrochureConnect.html

    It will not show visually correctly as I don't have the pictures/fonts (but will on your server)

    I see that you have some unused CSS, replace #counter to #ctr if you want a different look to the numbers.

    <style type="text/css">
    #counter{
    font-weight:bold;
    color:highlight;
    }
    Last edited by tonyp12; 02-04-2007 at 10:01 PM. Reason: 'setCtr()', 2000);, -changed to- 'setCtr()', 2000);

  • #13
    New to the CF scene
    Join Date
    Feb 2007
    Location
    england
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Tony, You are a star. I have no idea on these type of things, trying to learn though. What do I need to do to get the number to appear in bold?

    Many thanks again.
    Keith

  • #14
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To get bold, change the top of your html.

    Code:
    <html>
    <head>
    <title>mycounter</title>
    <meta http-equiv="Content-Language" content="en-gb">
    <title>-</title>
    <style type="text/css">
    #ctr{
    font-weight:bold;
    color:highlight;
    }
    </style>
    <META NAME="robots" CONTENT="all">
    <META NAME="title" CONTENT="Brochureconnect: Literature display and distribution services. Brochure display stands and leaflet displays.">
    <META NAME="description" CONTENT=""Use Brochureconnect to distribute and display literature, leaflets, brochures and tourist information, displayed using our own or your branded, brochure display stands. ">
    <META NAME="keywords" CONTENT="brochureco
    And delete this erronous text in red at bottom.

    Code:
    		<p>Brochure</font><font FACE="Tahoma" COLOR="#008000">Connect</font></b><font FACE="Tahoma"> 
    		<b>is dedicated to bringing you just this.</b></p>
    		</font><font SIZE="2" COLOR="#008000" face="Tahoma">
    		<p><b>We work hard to ensure your print is seen in your marketplace 
    		and produces optimum results for you.</b><html><body onload="setInterval('setCtr()', 2000);"><div>&nbsp;<span id="ctr"></span></div>
    </body>
    </html></font></td>
    				</tr>
    				</table>
    Last edited by tonyp12; 02-05-2007 at 03:12 AM.

  • #15
    New to the CF scene
    Join Date
    Feb 2007
    Location
    england
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Many thanks Tony.

    Keith


  •  

    Posting Permissions

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