-
July 10th, 2004, 04:57 AM
#1
JavaScript Help
I'm sure someone here must know some javascript, and I am hoping to get some help making something in it. Can someone possibly write me a code? Here is what I want.
I need a script that goes into the <head> , and then allows me to place the date anywhere in the page with another insertable thingy. I am not to up on javascript so try and stay with me... I need it to place JUST the date.
Like,
<head>
<script type=javascript
(blabda bldab
</script>
<body>
Today's date is <script that inserts date>
then I have a calendar already built below this.
BTW, this is ALL for my father, who runs a website for Special Olympics... for free... So you might be able to guess he doesn't work too teribly hard on it, and considers himself to old to learn a bunch of new stuff. If this was all for myself I would most certainly go and learn it myself, but I do not want to take the time to learn JS just for this. Thanks for any help...
[H]ard|OCP <--Best hardware/gaming news out there--|
pwned.nl <--Gamers will love this one --|
Light a man a fire and you\'ll keep him warm for a day, Light a man ON fire and you\'ll keep him warm the rest of his life.
-
July 10th, 2004, 05:31 AM
#2
Code:
date=new Date();
day=date.getDate();
year=date.getYear();
if (year < 2000) year=year+1900;
TodaysDate=" "+d[date.getDay()]+" "+day+" "+m[date.getMonth()]+" "+year;
TodaysDate would read Friday 9 July 2004 (as of this posting )
A mind full of questions has no room for answers
-
July 10th, 2004, 06:34 AM
#3
So what would I put where? Sorry, I'm not too good with JS... I need to go learn more but anyways.
[H]ard|OCP <--Best hardware/gaming news out there--|
pwned.nl <--Gamers will love this one --|
Light a man a fire and you\'ll keep him warm for a day, Light a man ON fire and you\'ll keep him warm the rest of his life.
-
July 10th, 2004, 05:27 PM
#4
Junior Member
There's a variety of scripts out there you could use. Here's a different one. You could place this in the head of the document, although I usually just place my site name, info, trackin info in the head? Either way..
<SCRIPT>
function tick() {
var hours, minutes, seconds, ap;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
ap = "It's midnight";
} else if (intHours < 12) {
hours = intHours+":";
ap = " AM";
} else if (intHours == 12) {
hours = "12:";
ap = "It's noon";
} else {
intHours = intHours - 12
hours = intHours + ":";
ap = " PM";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = hours+minutes+seconds+ap;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</SCRIPT>
<DIV id=Clock style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt"> </DIV>
-
July 11th, 2004, 10:19 AM
#5
Senior Member
If you want you can check out http://www.javascripts.com
you can get the readymade scripts for free there!!
Now is the moment, or NEVER!!!
-
July 13th, 2004, 11:12 AM
#6
Junior Member
hmm i have some way to do that. u can put javascript function in to another file like "script.js". and then u call it from your page like this
<head>
<title></title>
<script language="JavaScript" src="script.js">
</script>
</head>
and example to call that function like this.
<body topmargin="0" leftmargin="0" onLoad="myTime()">
the function myTime() are:
function myTime() {
var today = new Date()
var hours = today.getHours()
var minutes = today.getMinutes()
var seconds = today.getSeconds()
var suffix="AM"
if (hours >= 12) {
suffix="PM"
}
if (hours >= 13) {
hours-=12
} else if (hours == 0) {
hours = 12
}
if (minutes < 10) {
minutes = "0" + minutes
}
if (seconds < 10) {
seconds = "0" + seconds
}
var time = hours + ":" + minutes + ":" + seconds + " " + suffix
parent.header.time.value = time
timer = window.setTimeout("myTime()", 1000)
}
or u can exactly include the script itself to your html
<SCRIPT Language=JavaScript>
<!--
var mon = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var d = new Date();
var date = d.getDate();
var month = d.getMonth();
var year = d.getYear();
if (navigator.appName == 'Netscape') {
year = d.getYear() + 1900;
}
document.write(date + " " + mon[month] + " " + year);
-->
</SCRIPT>
Lord Xavier,
Cyberdelia Technologies,
(Wholly owned by Cyberdelia Group).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|