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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help on coding a Scritp Code

    I was wondering if someone can help me code this javascrpit code


    <script type="JavaScript">

    var elbow = new Date();
    var rib = elbow.getSeconds();

    if (rib<=30) rib=Yes;
    else if (rib<=60) rib=No;
    var msg ="+rib+";
    document.write(msg);

    </script>

  • #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,746
    Thanks
    0
    Thanked 244 Times in 239 Posts
    Hi there brokendownhitle,

    and a warm welcome to these forums.

    I would suggest that you do not use document.write.

    source:-
    Code:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script type="text/javascript">
    window.onload=function() {
      var elbow=new Date();
      var rib=elbow.getSeconds();
    
    if(rib<=30){ 
       rib='Yes';
     }
    else {
    if(rib<=60){ 
       rib='No';
      }
     }
     document.getElementById('msg').firstChild.nodeValue=rib;
     }
    </script>
    
    </head>
    <body>
    
    <div id="msg">&nbsp;</div>
    
    </body>
    </html>
    
    coothead

  • #3
    Regular Coder
    Join Date
    Oct 2006
    Posts
    107
    Thanks
    3
    Thanked 5 Times in 5 Posts
    I would suggest that you do not use document.write.
    It just keeps getting easier,


  •  

    Posting Permissions

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