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
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Clock not displaying in text field.

    I have the following script:

    Code:
    function liveclock() {
    
    var curdate  = new Date();
    
    var hours=curdate.getHours();
    
    var minutes=curdate.getMinutes();
    
    var seconds=curdate.getSeconds();
    
    var suffix="AM"
    
    var box=document.tee_One.tee_Two;
    
    if (hours>=12){
    suffix="PM";
    if (hours>=13)
    hours-=12
    }
    
    if (minutes<10)
    minutes= "0" + minutes;
    
    if (seconds<10)
    seconds= "0" + seconds;
    
    var thetime = hours+ ":" +minutes + ":" + seconds + " " +suffix;
    
    box.value = thetime;
    
    setTimeout("liveclock()",1000)
    }
    
    liveclock(); 
    The thing is, nothing is displayed in the content box. And i get no errors.
    LovesWar

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Comment first the setTimeout line and then put alert statements in the function to see where the code goes wrong.

    Something like:

    var box=document.tee_One.tee_Two;
    alert(box); //should alert [object] for IE
    Glenn
    ____________________________________

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


  •  

    Posting Permissions

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