HighDots Forums  

Placing Static Text (Phone Number) Below Printed Time

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Placing Static Text (Phone Number) Below Printed Time in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Fred
 
Posts: n/a

Default Placing Static Text (Phone Number) Below Printed Time - 01-04-2007 , 08:59 AM






I'm using a script that uses the computers clock and prints the date
on a html document.

I have been asked to place a phone number below the printed date.

This may sound like a simple request for most you guys but for newbies
like me its a nightmare.

Can you show me how to have the script place a phon number beneath the
printed date? Below is the script.


var dayarray=new
Array("Sunday","Monday","Tuesday","Wednesday","Thu rsday","Friday","Saturday")
var montharray=new
Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds

//This is where the date/time gets printed. I've tried inserting the
phone number here but I'm not using the correct syntax and the script
crashes. Can you help by showing me how print a phone number below
the time?

var cdate="<small><font color='000000'
face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+",
"+year+" "+hours+":"+minutes+" "+dn
+"</b></font></small>"

if (document.all)
document.all.clock.innerHTML=cdatem,
else if (document.getElementById)
//Class ID designator
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
//Body Onload Call
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}


Thanks for the help.
Fred

Reply With Quote
  #2  
Old   
Fred
 
Posts: n/a

Default Re: Placing Static Text (Phone Number) Below Printed Time - 01-04-2007 , 01:22 PM






On Thu, 04 Jan 2007 15:36:29 GMT, "Wayne Dobson"
<nospam (AT) noaddress (DOT) com> wrote:

Quote:
The above script had some unterminated strings and a misspelt variable, that
stopped it from working. Below is a tweaked version that updates, with
added seconds - which was left out. Adding a phone number below, is a
trivial task, involving attaching a "<BR>phone_number" to the end of the
string. Also, the script could have been written better.
Thank you!

1) <BR> to the end of the string? Got it.

2) There's no doubt in my mind that the script could be written
better. I wish I had the skills to clean it up. I know just enough
about JavaScript to really screw things up good. I'm guessing you know
my type.

3) FYI: I removed the seconds.

Thanks again.



Reply With Quote
Reply




Thread Tools
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.