ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 22nd, 2005, 04:53 PM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
CF/Javascript

I have this code... and it displays a dynamic clock on the title of the page... can someone help me change it so it just displays it on tehe body of a regular CF page? i know absolutely no javascript..

<script>
function getClock() {
document.title= updateClock(); // make a call to the updateClock() function to return the current time value
}

// this function uses settimeout function
function updateClock() {
var now = new Date();
var clock = setTimeout("getClock()", 1000); //update getClock() function
//////////////////////////////////////////
clock = now.getMonth()+1 + "/" + now.getDate() + "/" + now.getYear() + "-" + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
//////////////////////////////////////////
return clock;
}
// this is more like an endless loop where two functions call each other
</script>

<!---------------------------------------------------------------------->
<body onLoad="getClock()">
<h2>
Watch the title on your page. See time slip out of your hands !
</h2>

Reply With Quote
  #2  
Old January 24th, 2005, 10:04 AM
VelvettFogg VelvettFogg is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 34 VelvettFogg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 13 m 46 sec
Reputation Power: 4
Charmed -- I belive that we are missing some code here. The javascript that you've posted is the "clock", but there is no code that I see that tells your browser "where" to display the clock.

<body onLoad="getClock()">

That line tells the clock to start running, but there *has* to be code that displays the clock. This clock is on the page's title bar? So ... can you paste the <title> tag?

Reply With Quote
  #3  
Old January 24th, 2005, 12:25 PM
r937's Avatar
r937 r937 is online now
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,959 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 16 h 14 m 44 sec
Reputation Power: 1024
the initial contents of the title tag don't matter

document.title= updateClock(); // updates the title

that said, i think this use of javascript is abysmal

i don't need to visit a web site to find out what time it is

__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon

Reply With Quote
  #4  
Old January 24th, 2005, 12:35 PM
VelvettFogg VelvettFogg is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 34 VelvettFogg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 13 m 46 sec
Reputation Power: 4
doh! I missed that line of code (document.title= updateClock() the first time I read the post.

Charmed -- you simply need to change this part document.title= updateClock(); to update the portion of the page that you want to have the clock. Something along the linest of ...

document.all.nameOftheSpanThatHasTheClock = updateClock();

Reply With Quote
  #5  
Old January 24th, 2005, 03:29 PM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
I posted i didnt know any javascript so is there any chance i can get a little more help on this? i just want the clock displayed on the page not the title.. i dont know what that line even means, so i dont know how to change it... i pasted what you put but it just takes it off the title, but doesnt put it on the page

Quote:
Originally Posted by VelvettFogg
doh! I missed that line of code (document.title= updateClock() the first time I read the post.

Charmed -- you simply need to change this part document.title= updateClock(); to update the portion of the page that you want to have the clock. Something along the linest of ...

document.all.nameOftheSpanThatHasTheClock = updateClock();

Reply With Quote
  #6  
Old January 24th, 2005, 03:46 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
There's a whole forum on Javascript development here at Devshed, you might want to ask there.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > CF/Javascript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT