[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference abbott::java

Title:JAVA
Moderator:KOALA::CIOT
Created:Mon Nov 13 1995
Last Modified:Wed Jun 04 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:236
Total number of notes:1251

221.0. "Can you loop on a document.write() command?" by SCAMP::SMITH (Never say never, I always say.) Thu Apr 17 1997 22:16

Is there an easy way (or any way at all) to "loop" on
a document.write command?

I'm displaying a "time-of-day" on a Web Page and would
like it to update each second.  All the examples I've
seen have had the clock in a Table, but mine is just
written to the page like text, sort of.  As usual, I
can't figure it out.  :^(

It can be seen at: http://members.aol.com/mtnbykmike

It's the "red" time near the bottom.

Here's the code if you don't want to go there:


<B><FONT Color="#ffff00">

Your PC thinks today is<br>

<script language="JavaScript">

<!--Hide from wimpy Browsers

var days = new Array(7)
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";

var months = new Array(12)
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";

var today = new Date()
var day = days[today.getDay() + 1]
var month = months[today.getMonth() + 1]
var date = today.getDate()
var year = "19" + today.getYear()

document.write(day + ", " + month + " " + date + ", " + year + "\n")

//Stop hiding-->

</script><br>

and the time is

<FONT Color="#ff0000">

<script language="JavaScript">

<!--Hide from wimpy Browsers

var TODAY   = new Date()
var HOURS   = today.getHours()
var MINUTES = today.getMinutes()
var SECONDS = today.getSeconds()
var CurrentTime  = ((HOURS>12) ? (HOURS-12) : HOURS)
    CurrentTime += ((MINUTES < 10) ? ":0" : ":") + MINUTES
    CurrentTime += ((SECONDS < 10) ? ":0" : ":") + SECONDS
    CurrentTime += ((HOURS >= 12) ? "pm" : "am")

document.write(CurrentTime)

//Stop hiding-->

</script></B></font><P><BR>

</center>
</body>
</html>

Thanks!

Mike

T.RTitleUserPersonal
Name
DateLines
221.1Per Second UpdateAVANT::CHOUFri Apr 18 1997 15:498
    Check out this page:  http://www.rhoque.com/book   The second example
    in the "Sample: Chapter 5" does a per second update.  It might help.
    
    Cool page you got.  One suggestion if you don't mind...you may want to
    include a text_only page for all the links you have because it can take a 
    long time for some people to get all the graphics loaded.  :-)
    
    Novey
221.2It was in a Table, but it's a start...NQOS01::nqodhcp-135-56-69.nqo.dec.com::SmithNever say never, I always say!Mon May 05 1997 10:5813
Thanks, Novey.  All I could find there was something
to have the time running within a little box (a Table).
But, it's a start.

Yeah, my Web Pages do have a lot of graphics, but once
Gates gets all those satellites (840 of 'em, starting in
the year 2000) launched, Network Connectivity will
"speed up".  :^)

Mike