clock..

  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

As far as your problem, try taking the form tags out and see if it still works. I think it will. Let me know.
  • ED
  • Student
  • Student
  • ED
  • Posts: 66
  • Loc: Halifax

Post 3+ Months Ago

i've got your solution...
hold up
brb... i'm writting the code
  • ED
  • Student
  • Student
  • ED
  • Posts: 66
  • Loc: Halifax

Post 3+ Months Ago

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
  • ED
  • Posts: 66
  • Loc: Halifax

Post 3+ Months Ago

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
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

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
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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.
  • ED
  • Student
  • Student
  • ED
  • Posts: 66
  • Loc: Halifax

Post 3+ Months Ago

try it again it should work
or grab the source from

http://toptgpz.com/javaclock.html

it works there for sure.
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

its at http://www.onspring.co.uk
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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">
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

yea i found that one aswel but it still doesnt work lol
D7
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Well upload the change, so I can see.
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

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
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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.
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

i thank you for ur help with it but i decided to change it altogether so i took out some of the tables and put frames in instead and used a java applet clock that was provided with the hosting im sorry if i put u out or anything
D7
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

No problem man, your call. Ed's script works though, I have seen it in action.

Post Information

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

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.