HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
HELP!! how to display TIME STAMP to the other CELL
Post new topic   Reply to topic    HTML Help Forum Index -> Javascript
View previous topic :: View next topic  
Author Message
jhydes19



Joined: 07 Mar 2009
Posts: 1

PostPosted: Sat Mar 07, 2009 8:14 pm     HELP!! how to display TIME STAMP to the other CELL Reply with quote

Anyone, please I need help on how to display TIME STAMP to the other CELL.. I would like to create a website where I can click a button then it will display the time stamp next to it in html code..

can you correct my code?

<SCRIPT LANGUAGE="JavaScript">
function TIMESTAMP();
{
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " P.M.";
}
else {
Time = " A.M.";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;

str = ''
str +=Hours + ":"
str +=Mins + "
str +=Time + " "
str +=Stamp()

document.getElementById('TIMESTAMP').innerHTML = str

}
</script>
<table width="400" border="1" cellspacing="0" cellpadding="2">
<tr>
<td width="100">
<div align="center">
<input type="button" name="Button" value="Click Me"

onclick="TIMESTAMP()" />
</div></td>
<td><div id="myDiv">&nbsp;</div></td>
</tr>
</table>
</SCRIPT>
nagasree



Joined: 21 Sep 2004
Posts: 82
Location: Hyderabad, India

PostPosted: Fri Mar 13, 2009 12:33 am     Reply with quote

Try This

Code:

<SCRIPT LANGUAGE="JavaScript">
function TIMESTAMP()
{
   var Stamp = new Date()
   var Hours;
   var Mins;
   var Time;
   Hours = Stamp.getHours();
   if (Hours >= 12) {
      Time = " P.M.";
   }
   else {
      Time = " A.M.";
   }
   if (Hours > 12) {
      Hours -= 12;
   }
   if (Hours == 0) {
      Hours = 12;
   }
   Mins = Stamp.getMinutes();
   if (Mins < 10) {
      Mins = "0" + Mins;
   }
   str = ''
   str += (Stamp.getMonth() < 10 ? "0" + (Stamp.getMonth() + 1) : Stamp.getMonth() + 1 )
         + "/" + (Stamp.getDate() < 10 ? "0" + Stamp.getDate() : Stamp.getDate() )
         +  "/" + Stamp.getYear() + " "
   str +=Hours + ":"
   str +=Mins + ":"
   str += Time + " "
   

   document.getElementById('myDiv').innerHTML = str

}
</script>
<table width="400" border="1" cellspacing="0" cellpadding="2">
<tr>
<td width="100">
<div align="center">
<input type="button" name="Button" value="Click Me"

onclick="TIMESTAMP()" />
</div></td>
<td><div id="myDiv">&nbsp;</div></td>
</tr>
</table>


-Nagasree
Ujujboypiano



Joined: 30 Sep 2009
Posts: 5

PostPosted: Wed Sep 30, 2009 12:50 pm     Hi i know a way to create a moving clock Reply with quote

I know a time script
It has a bit of CSS but no CSS external files Very Happy
Head script:
<script language="JavaScript">
<!--
function getTime() {
var second= new Array(60)
second[0]="00"
second[1]="01"
second[2]="02"
second[3]="03"
second[4]="04"
second[5]="05"
second[6]="06"
second[7]="07"
second[8]="08"
second[9]="09"
second[10]="10"
second[11]="11"
second[12]="12"
second[13]="13"
second[14]="14"
second[15]="15"
second[16]="16"
second[17]="17"
second[18]="18"
second[19]="19"
second[20]="20"
second[21]="21"
second[22]="22"
second[23]="23"
second[24]="24"
second[25]="25"
second[26]="26"
second[27]="27"
second[28]="28"
second[29]="29"
second[30]="30"
second[31]="31"
second[32]="32"
second[33]="33"
second[34]="34"
second[35]="35"
second[36]="36"
second[37]="37"
second[38]="38"
second[39]="39"
second[40]="40"
second[41]="41"
second[42]="42"
second[43]="43"
second[44]="44"
second[45]="45"
second[46]="46"
second[47]="47"
second[48]="48"
second[49]="49"
second[50]="50"
second[51]="51"
second[52]="52"
second[53]="53"
second[54]="54"
second[55]="55"
second[56]="56"
second[57]="57"
second[58]="58"
second[59]="59"
var minute= new Array(60)
minute[0]="00"
minute[1]="01"
minute[2]="02"
minute[3]="03"
minute[4]="04"
minute[5]="05"
minute[6]="06"
minute[7]="07"
minute[8]="08"
minute[9]="09"
minute[10]="10"
minute[11]="11"
minute[12]="12"
minute[13]="13"
minute[14]="14"
minute[15]="15"
minute[16]="16"
minute[17]="17"
minute[18]="18"
minute[19]="19"
minute[20]="20"
minute[21]="21"
minute[22]="22"
minute[23]="23"
minute[24]="24"
minute[25]="25"
minute[26]="26"
minute[27]="27"
minute[28]="28"
minute[29]="29"
minute[30]="30"
minute[31]="31"
minute[32]="32"
minute[33]="33"
minute[34]="34"
minute[35]="35"
minute[36]="36"
minute[37]="37"
minute[38]="38"
minute[39]="39"
minute[40]="40"
minute[41]="41"
minute[42]="42"
minute[43]="43"
minute[44]="44"
minute[45]="45"
minute[46]="46"
minute[47]="47"
minute[48]="48"
minute[49]="49"
minute[50]="50"
minute[51]="51"
minute[52]="52"
minute[53]="53"
minute[54]="54"
minute[55]="55"
minute[56]="56"
minute[57]="57"
minute[58]="58"
minute[59]="59"
var hour= new Array(24)
hour[0]="00 AM"
hour[1]="01 AM"
hour[2]="02 AM"
hour[3]="03 AM"
hour[4]="04 AM"
hour[5]="05 AM"
hour[6]="06 AM"
hour[7]="07 AM"
hour[8]="08 AM"
hour[9]="09 AM"
hour[10]="10 AM"
hour[11]="11 AM"
hour[12]="12 PM"
hour[13]="01 PM"
hour[14]="02 PM"
hour[15]="03 PM"
hour[16]="04 PM"
hour[17]="05 PM"
hour[18]="06 PM"
hour[19]="07 PM"
hour[20]="08 PM"
hour[21]="09 PM"
hour[22]="10 PM"
hour[23]="11 PM"
var weekday= new Array(7)
weekday[0]="Sun"
weekday[1]="Mon"
weekday[2]="Tue"
weekday[3]="Wed"
weekday[4]="Thu"
weekday[5]="Fri"
weekday[6]="Sat"
var thetime=new Date();
var nweekdays=thetime.getDay();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecs=thetime.getSeconds();
var seconds=second[nsecs]
var minutes=minute[nmins]
var hours=hour[nhours]
var weekdays=weekday[nweekdays]
var localTime="Day: "+weekdays+", Hour: "+hours+", Minute: "+minutes+", Second: "+seconds
document.getElementById("clock").innerHTML = localTime;
}
-->
</script>
<noscript>
JavaScript is either not supported by your browser or not turned on. Upgrade your browser or turn on JavaScript to get the full functionality of this web site.
</noscript>
<style>
<!--
.clock {color:#FFCC00; background-color:#000000}
-->
</style>



Body Script:
<body onLoad="getTime(); setInterval('getTime()', 1 )">
<h1>
The time is:
</h1>
<br>
<table bordercolor="#FFCC00" border="1">
<tr>
<td>
<div id="clock" class="clock">
Loading...
</div>
</td>
</tr>
</table>
That's it! It's about 4.21 KB. Shocked
PLZ TELL ME ERRORS
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> Javascript All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial