clock..

  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post March 8th, 2003, 1:27 pm

well ive looked for a clock to put on my site and the ones ive found have been javascript ones with a form text area here is the code for it:

<SCRIPT LANGUAGE="JavaScript">
<!-- Clock --
var timerID = null
var timerRunning = false

function stopclock(){
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}

function startclock(){
stopclock()
showtime()
}

function showtime(){
var now = new Date()
var hours = now.getHours()
var minutes = now.getMinutes()
var seconds = now.getSeconds()
var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
document.clock.face.value = timeValue
timerID = setTimeout("showtime()",1000)
timerRunning = true
}
//-->
</SCRIPT>
<BODY onLoad="startclock()">
<!-------------------------------------------------------------------------------------------->
<form name="clock" onSubmit="0">
#INPUT TYPE="text" NAME="face" SIZE=11 VALUE ="....Initializing....">
</form>

I want to know if i can take the form thing out because i want to put it into <td> tags in a table any help wud b much appreciated
D7
ps the # is there instead of the < cos otherwise u cant see the code
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 8th, 2003, 1:27 pm

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post March 8th, 2003, 1:47 pm

When you put code in this forum hit the code button first.. then copy and paste your code in, and then hit the code button again when you are done. This will allow all your code to be shown right and you wont have to worry about putting that # sign and stuff
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post March 8th, 2003, 1:48 pm

As far as your problem, try taking the form tags out and see if it still works. I think it will. Let me know.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • ED
  • Student
  • Student
  • No Avatar
  • Joined: Jan 02, 2003
  • Posts: 66
  • Loc: Halifax
  • Status: Offline

Post March 8th, 2003, 2:03 pm

i've got your solution...
hold up
brb... i'm writting the code
  • ED
  • Student
  • Student
  • No Avatar
  • Joined: Jan 02, 2003
  • Posts: 66
  • Loc: Halifax
  • Status: Offline

Post March 8th, 2003, 2:10 pm

k
got it

here is the code
I wrote it myself :D
working example here
http://toptgpz.com/javaclock.html
you can view the sorce there if you like


Code: [ Select ]
<script language="JavaScript">
<!--
var ampm="am";
function UpdateClock() {
  var tDate = new Date();
  var printh=tDate.getHours();
  var printm=tDate.getMinutes();
  var prints=tDate.getSeconds();

  if(prints<10){prints="0"+prints;}
  if(printm<10){printm="0"+printm;}

  if(printh>12){printh-=12;ampm="pm";}
   clock.firstChild.nodeValue="" + printh + ":" + printm + ":" + prints+" "+ampm;
   clockID = setTimeout("UpdateClock()", 1000);
}
UpdateClock();
//-->
</script>
  1. <script language="JavaScript">
  2. <!--
  3. var ampm="am";
  4. function UpdateClock() {
  5.   var tDate = new Date();
  6.   var printh=tDate.getHours();
  7.   var printm=tDate.getMinutes();
  8.   var prints=tDate.getSeconds();
  9.   if(prints<10){prints="0"+prints;}
  10.   if(printm<10){printm="0"+printm;}
  11.   if(printh>12){printh-=12;ampm="pm";}
  12.    clock.firstChild.nodeValue="" + printh + ":" + printm + ":" + prints+" "+ampm;
  13.    clockID = setTimeout("UpdateClock()", 1000);
  14. }
  15. UpdateClock();
  16. //-->
  17. </script>


if you want to put the code into a TD
use

Code: [ Select ]
<td ID="clock">init</td>

there HAS to be something inside the TD tag to start or it will create a null pointer error.


you can also put it into <H> tags
  • ED
  • Student
  • Student
  • No Avatar
  • Joined: Jan 02, 2003
  • Posts: 66
  • Loc: Halifax
  • Status: Offline

Post March 8th, 2003, 2:21 pm

After a little testing
you can also put it into <H>, <p>, and <font>

whoa... the font tag surprised me..
i was thinking of an easy way to control the font inside of a TD tag without CSS..
cause this doesn't work

Code: [ Select ]
<td ID="clock"><font size=+2>initalizing</font></td>


to my surprise
this does work
Code: [ Select ]
<font ID="clock" size=+2>init</font>
  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post March 8th, 2003, 2:28 pm

it says there is an error wen i try to have a look at it cos it says that there is a script error and that it expects a ";" after:
if(printh>12){printh-=12;ampm="pm";}
it cud b ur code or it cud b the way ive set it in the html i dont know u tell me lol
D7
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post March 8th, 2003, 2:33 pm

Show us the link to your page you are having that problem on. I have a feeling you didn't place the code ED suggested correctly.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • ED
  • Student
  • Student
  • No Avatar
  • Joined: Jan 02, 2003
  • Posts: 66
  • Loc: Halifax
  • Status: Offline

Post March 8th, 2003, 2:38 pm

try it again it should work
or grab the source from

http://toptgpz.com/javaclock.html

it works there for sure.
  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post March 8th, 2003, 2:42 pm

its at http://www.onspring.co.uk
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post March 8th, 2003, 3:24 pm

Well I see one problem already. You did not copy his code exactly. For instance your first line you copied looks like this in your source

Code: [ Select ]
<script type="text/javascript"


It should look like

Code: [ Select ]
<script type="text/javascript">
or
Code: [ Select ]
<script language="JavaScript">
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post March 8th, 2003, 3:25 pm

yea i found that one aswel but it still doesnt work lol
D7
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post March 8th, 2003, 3:26 pm

Well upload the change, so I can see.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • dreamer7
  • Student
  • Student
  • No Avatar
  • Joined: Jan 20, 2003
  • Posts: 96
  • Loc: UK
  • Status: Offline

Post March 8th, 2003, 3:34 pm

wel its up with the modification of a > lol but now it says that there is no errors on the page which is quite confusing considering it still doesnt work :(
D7
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post March 8th, 2003, 6:14 pm

Okay try this. I noticed you put all that javascript code actually right after the TD tag. Place all that code in your head area of your page. And then after where it says

Code: [ Select ]
<TD WIDTH="175" HEIGHT="35" ALIGN="center" ID="clock">


put a few words like "clock will show here" so it might end up looking like this

Code: [ Select ]
<TD WIDTH="175" HEIGHT="35" ALIGN="center" ID="clock">clock will show here


so that you make sure you can see just plain text. If that doesn't even work then its just the way you have your table or something. Anyway try that and upload your changes and we will go from there.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 8th, 2003, 6:14 pm

Post Information

  • Total Posts in this topic: 17 posts
  • Users browsing this forum: No registered users and 138 guests
  • 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 post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.