Hello everyone. I have 2 scripts in which one was actually created using another. Both of the scripts work great individually, however, when I put them in the same page only the one called first runs.
Here is the HTML test page
[code=html]<html>
<head>
<title>TEST</title>
<script language=”javascript” src=”date.js”></script>
<script language=”javascript” src=”time.js”></script>
</head>
<body onload=”date()” onload=”time()”>
<span id=”date”></span><br>
<span id=”time”></span>
</body>
</html>
Here is date.js
[CODE]function date() {
var mydate = new Date();
var year = mydate.getFullYear();
var day = mydate.getDay();
var month = mydate.getMonth();
var daym = mydate.getDate();
if (daym<10)
daym=”0″+daym;
var dayarray = new Array(“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”);
var montharray = new Array(“Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Aug”,”Sep”,”Oct”,”Nov”,”Dec”);
dispDate = “<span class=’datetime’>” + dayarray[day] + “, ” + montharray[month] + ” ” + daym + “, ” + year + “</span>”;
var e = document.getElementById(“date”);
if(!e)return;
if(“innerHTML” in e)e.innerHTML = dispDate;
setTimeout(“date()”, 1000);
}
Here is time.js
[CODE]function time() {
var digital = new Date();
var hours = digital.getHours();
var minutes = digital.getMinutes();
var seconds = digital.getSeconds();
var amOrPm = “AM”;
if (hours > 11) amOrPm = “PM”;
if (hours > 12) hours = hours – 12;
if (hours == 0) hours = 12;
if (minutes <= 9) minutes = “0” + minutes;
if (seconds <= 9) seconds = “0” + seconds;
dispTime = “<span class=’datetime’>” + hours + “:” + minutes + “:” + seconds + ” ” + amOrPm + “</span>”;
var e = document.getElementById(“time”);
if(!e)return;
if(“innerHTML” in e)e.innerHTML = dispTime;
setTimeout(“time()”, 1000);
}
Can anyone tell me how to make these scripts exist simultaneously? I hope so, because I’ve been trying to get these 2 scripts the way they are now pretty hard for them not to be able to work together ? . Thanks.
lonogod