Web Design and Development Forums

inserting time

This is a discussion on "inserting time" within the JavaScript Forum section. This forum, and the thread "inserting time are both part of the Program Your Website category.

Old May 1st, 2008, 09:55   #1 (permalink)
New Member
 
Join Date: May 2008
Location: Indian
Age: 28
Posts: 1
inserting time

I want a button on my website which when clicked inserts the current time in corresponding textarea.

Please note that i dont want to keep showing teh current time. I want the current time to be inserted in the textbox when the button is clicked.

Here is the code what i tried. Please highlight any errors to make it work correctly:
Code: Select all
<form name = "myForm">
<input type = "button" value = "Click To Insert Current Time" onclick = "setClock()">
<input type = "text" name = "timeDisplay">

<script type="text/javascript">
function setClock() {
var today = new Date();
var hh = today.getHours();
if (hh <10) {hh = "0" + hh};
var mm = today.getMinutes();
if (mm <10) {mm = "0" + mm};
var ss = today.getSeconds();
if (ss <10) {ss = "0" + ss};
var time = hh + ":" + mm + ":" + ss;
document.myform.timeDisplay.value = time;
}
</script>

Last edited by aso186; May 2nd, 2008 at 20:08. Reason: Use [code] tags
phiero21 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 2nd, 2008, 20:09   #2 (permalink)
Chief Moderator
 
aso186's Avatar
 
Join Date: Oct 2007
Location: UK
Posts: 715
Blog Entries: 2
Send a message via Skype™ to aso186
Re: inserting time

Moved to JavaScript Forum
__________________

aso186 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
DOM - Inserting <script> between <head> okendoze JavaScript Forum 2 Mar 13th, 2008 21:52
Inserting a XML variable in to a getURL dangergeek Flash & Multimedia Forum 1 Nov 14th, 2007 09:21
Need help in inserting audio using <object> shevorne Flash & Multimedia Forum 8 Sep 29th, 2007 13:39
help me with inserting images on webpage... renren HTML Forum 7 Jan 24th, 2006 12:32
Adjusting time from server time to local time Tim356 ASP Forum 10 Jun 21st, 2004 14:57



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 23:34.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59