Results 1 to 3 of 3

Thread: Local Time script + input type text

  1. #1
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Local Time script + input type text

    1) Script Title: Local Time script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex6/localtime.htm

    3) Describe problem:
    How can I put the received time in a form input text and not in a div/span tag.



    sorry the bad English...

    Thanx for your help!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Use this modified function in place of the one in the script:

    Code:
    showLocalTime.prototype.updateContainer=function(){
    var thisobj=this
    if (this.displayversion=="long"){
    if(this.container.tagName.toLowerCase()=='input')
    this.container.value=this.localtime.toLocaleString()
    else
    this.container.innerHTML=this.localtime.toLocaleString()
    }
    else{
    var hour=this.localtime.getHours()
    var minutes=this.localtime.getMinutes()
    var seconds=this.localtime.getSeconds()
    var ampm=(hour>=12)? "PM" : "AM"
    var dayofweek=weekdaystxt[this.localtime.getDay()]
    if(this.container.tagName.toLowerCase()=='input')
    this.container.value=formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" "+ampm+" ("+dayofweek+")"
    else
    this.container.innerHTML=formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" "+ampm+" ("+dayofweek+")"
    }
    setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second
    }
    And, instead of this:

    HTML Code:
    Current Server Time:<span id="timecontainer"></span>
    Use this:

    HTML Code:
    Current Server Time:<input type="text" id="timecontainer">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It worked fine!

    Thanks for your help!!!

Bookmarks

Posting Permissions

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