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 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript help ?

    I made a clock using JavaScript, the code is this :

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
        <head>
            <meta http-equiv="content-type" content="text/html;charset=utf-8" />
            <meta name="generator" content="Adobe GoLive" />
            <title>Digital Clock</title>
        
        
        <script language="JavaScript">
        
        
        
        
          var time = new Date()
          var hourx = time.getHours()
          var minutes = time.getMinutes()
         
        
        function minutes_2()
        {
         switch (minutesx){
           case 0:
           document.write("<img rc='0.gif'>" ,"<img src='0.gif'>");
           break
           case 1:
           document.write("<img src='0.gif'>" ,"<img src='1.gif'>");
           break
           case 2:
           document.write("<img src='0.gif'>" ,"<img src='2.gif'>");
           break
           case 3:
           document.write("<img src='0.gif'>" ,"<img src='3.gif'>");
           break
           case 4:
           document.write("<img src='0.gif'>", "<img src='4.gif'>");
           break
           case 5:
           document.write("<img src='0.gif'>", "<img src='5.gif'>");
           break
           case 6:
           document.write("<img src='0.gif'>", "<img src='6.gif'>");
           break  
           case 7:
           document.write("<img src='0.gif'>", "<img src='7.gif'>");
           break
           case 8:
           document.write("<img src='0.gif'>", "<img src='8.gif'>");
           break    
           case 9:
           document.write("<img src='0.gif'>" ,"<img src='9.gif'>");
           break
           case 10:
           document.write("<img src='1.gif'>" ,"<img src='0.gif'>");
           break
           case 11:
           document.writeln("<img src='1.gif'>", "<img src='1.gif'>");
           break
           case 12:
           document.write("<img src='1.gif'>", "<img src='2.gif'>");
           break
           case 13:
           document.writeln("<img src='1.gif'>", "<img src='3.gif'>");
           break
           case 14:
           document.write("<img src='1.gif'>", "<img src='4.gif'>");
           break
           case 15:
           document.write("<img src='1.gif'>", "<img src='5.gif'>");
           break
           case 16:
           document.write("<img src='1.gif'>", "<img src='6.gif'>");
           break
           case 17:
           document.write("<img src='1.gif'>", "<img src='7.gif'>");
           break
           case 18:
           document.write("<img src='1.gif'>", "<img src='8.gif'>");
           break
           case 19:
           document.write("<img src='1.gif'>", "<img src='9.gif'>");
           break
           case 20:
           document.write("<img src='2.gif'>", "<img src='0.gif'>");
           break
           case 21:
           document.write("<img src='2.gif'>", "<img src='1.gif'>");
           break
           case 22:
           document.write("<img src='2.gif'>", "<img src='2.gif'>");
           break
           case 23:
           document.write("<img src='2.gif'>", "<img src='3.gif'>");
           break
           case 24:
           document.write("<img src='2.gif'>", "<img src='5.gif'>");
           break
           case 25:
           document.write("<img src='2.gif'>", "<img src='5.gif'>");
           break
           case 26:
           document.write("<img src='2.gif'>", "<img src='6.gif'>");
           break
           case 27:
           document.write("<img src='2.gif'>", "<img src='7.gif'>");
           break
           case 28:
           document.write("<img src='2.gif'>", "<img src='8.gif'>");
           break
           case 29:
           document.write("<img src='2.gif'>", "<img src='9.gif'>");
           break
           case 30:
           document.write("<img src='3.gif'>", "<img src='0.gif'>");
           break
           case 31:
           document.write("<img src='3.gif'>", "<img src='1.gif'>");
           break
           case 32:
           document.write("<img src='3.gif'>", "<img src='2.gif'>");
           break
           case 33:
           document.write("<img src='3.gif'>", "<img src='3.gif'>");
           break
           case 34:
           document.write("<img src='3.gif'>", "<img src='4.gif'>");
           break
           case 35:
           document.write("<img src='3.gif'>", "<img src='5.gif'>");
           break
           case 36:
           document.write("<img src='3.gif'>", "<img src='6.gif'>");
           break
           case 37:
           document.write("<img src='3.gif'>", "<img src='7.gif'>");
           break
           case 38:
           document.write("<img src='3.gif'>", "<img src='8.gif'>");
           break
           case 39:
           document.write("<img src='3.gif'>", "<img src='9.gif'>");
           break
           case 40:
           document.write("<img src='4.gif'>", "<img src='0.gif'>");
           break
           case 41:
           document.write("<img src='4.gif'>", "<img src='1.gif'>");
           break
           case 42:
           document.write("<img src='4.gif'>", "<img src='2.gif'>");
           break
           case 43:
           document.write("<img src='4.gif'>", "<img src='3.gif'>");
           break
           case 44:
           document.write("<img src='4.gif'>", "<img src='4.gif'>");
           break
           case 45:
           document.write("<img src='4.gif'>", "<img src='5.gif'>");
           break
           case 46:
           document.write("<img src='4.gif'>", "<img src='6.gif'>");
           break
           case 47:
           document.write("<img src='4.gif'>", "<img src='7.gif'>");
           break
           case 48:
           document.write("<img src='4.gif'>", "<img src='8.gif'>");
           break
           case 49:
           document.write("<img src='4.gif'>", "<img src='9.gif'>");
           break
           case 50:
           document.write("<img src='5.gif'>", "<img src='0.gif'>");
           break
           case 51:
           document.write("<img src='5.gif'>", "<img src='1.gif'>");
           break
           case 52:
           document.write("<img src='5.gif'>", "<img src='2.gif'>");
           break
           case 53:
           document.write("<img src='5.gif'>", "<img src='3.gif'>");
           break
           case 54:
           document.write("<img src='5.gif'>", "<img src='4.gif'>");
           break
           case 55:
           document.write("<img src='5.gif'>", "<img src='5.gif'>");
           break
           case 56:
           document.write("<img src='5.gif'>", "<img src='6.gif'>");
           break
           case 57:
           document.write("<img src='5.gif'>", "<img src='7.gif'>");
           break
           case 58:
           document.write("<img src='5.gif'>", "<img src='8.gif'>");
           break
           case 59:
           document.write("<img src='5.gif'>", "<img src='9.gif'>");       
           break
           default: document.write("Clock contains errors")
           }
        
        } 
        
          function displayClock()
          {
          switch (hourx) {
          
          case 0:
          document.write("<img src='1.gif'>", "<img src='2.gif'>");
          break
          
          case 1:
          document.write("<img src='0.gif'>", "<img src='1.gif'>");
          break
          
          case 2:
          document.write("<img src='0.gif'>", "<img src='2.gif'>");
          
          break
          case 3:
          document.write("<img src='0.gif'>", "<img src='3.gif'>");
         
          break
          case 4:
          document.write("<img src='0.gif'>", "<img src='4.gif'>");
         
          break
          case 5:
          document.write("<img src='0.gif'>", "<img src='5.gif'>");
        
          break
          case 6:
          document.write("<img src='0.gif'>", "<img src='6.gif'>");
         
          break
          case 7:
          document.write("<img src='0.gif'>", "<img src='7.gif'>");
         
          break
          case 8:
          document.write("<img src='0.gif'>", "<img src='8.gif'>");
        
          break
          case 9:
          document.write("<img src='0.gif'>", "<img src='9.gif'>");
          
          break
          case 10:
          document.write("<img src='1.gif'>", "<img src='0.gif'>");
        
          break
          case 11:
          document.write("<img src='1.gif'>", "<img src='1.gif'>");
          
          break
          case 12:
          document.write("<img src='1.gif'>", "<img src='2.gif'>");
         
          break
          case 13:
          document.write("<img src='0.gif'>", "<img src='1.gif'>");
         
          break
          case 14:
          document.write("<img src='0.gif'>", "<img src='2.gif'>");
          
          break  
          case 15:
          document.write("<img src='0.gif'>", "<img src='3.gif'>");
          
          break      
          case 16:
          document.write("<img src='0.gif'>", "<img src='4.gif'>");
         
          break
          case 17:
          document.write("<img src='0.gif'>", "<img src='5.gif'>");
          
          break
          case 18:
          document.write("<img src='0.gif'>", "<img src='6.gif'>");
        
          break
          case 19:
          document.write("<img src='0.gif'>", "<img src='7.gif'>");
        
          break
          case 20:
          document.write("<img src='0.gif'>", "<img src='8.gif'>");
          
          break
          case 21:
          document.write("<img src='0.gif'>", "<img src='9.gif'>");
         
          break
          case 22:
          document.write("<img src='1.gif'>", "<img src='0.gif'>");
         
          break
          case 23:
          document.write("<img src='1.gif'>", "<img src='1.gif'>");
          
          break
          default: document.write("Clock is dead");      
          }
        } 
        
        
        
        
        
        
        
        
        </script>
        </head>
    
        <body>
        
        <script language="JavaScript">
        
        displayClock()+minutes_2()
        
        </script>
        
        </body>
    
    </html>
    I want the time to change automatically as time changes. how do i do that ? the time is displayed using gif. pictures. i tried using setTimeout and setInterval...its still not working...pls help...
    Last edited by joshuadavid2007; 06-18-2007 at 11:30 AM.

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    First things first…

    1. Edit your post and remove all the colour, size and bold tags.
      Trying to present your post in that way is excessive.
      Use bold and size tags sparingly when relevant. When eveything is 'emphasised', nothing is emphasised.

    2. Place your code between [code]…[/code] tags.

    3. Refrain from presenting your posts in that way in future.


    …then you might find people more willing to engage with you and respond to your query.


    p.s. Welcome to the forum.


    Edit:

    p.p.s. It's great that you edited this thread, so why post it again?

    Last edited by Bill Posters; 06-18-2007 at 02:28 PM.


  •  

    Posting Permissions

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