apt
25-06-2000, 20:32
I know not how to edit Javascript - I just cut 2 separate scripts from a website resource -the problem is I want to put these 2 separate bits on the SAME LINE. The first part simply writes the current date while the second script displays the current time as a clock in a Form.
If you can amalgamate the two so they appear next to one another on the same line I'd be very grateful. I have absolutely no idea how to do it! The "date" script just has a BODY bit, and the "clock" has a HEAD and BODY part. To edit the script you'll need to cut it from the EDIT option just above this message! Many thanks and good luck?!
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
d = new Array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
);
m = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
);
today = new Date();
day = today.getDate();
year = today.getYear();
if (year < 2000) // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
end = "th";
if (day==1 | | day==21 | | day==31) end="st";
if (day==2 | | day==22) end="nd";
if (day==3 | | day==23) end="rd";
day+=end;
document.write(" ");
document.write(d[today.getDay()]+", "+m[today.getMonth()]+" ");
document.write(day+", " + year);
document.write("</center>");
// End -->
</script>
</BODY>
<!--************************************-->
<HEAD>
<SCRIPT language="JavaScript">
<!--
function startclock()
{
var thetime=new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var AorP=" ";
if (nhours>=12)
AorP="pm.";
else
AorP="am.";
if (nhours>=13)
nhours-=12;
if (nhours==0)
nhours=12;
if (nsecn<10)
nsecn="0"+nsecn;
if (nmins<10)
nmins="0"+nmins;
document.clockform.clockspot.value=nhours+": "+nmins+": "+nsecn+" "+AorP;
setTimeout('startclock()',1000);
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM name="clockform">
<INPUT TYPE="text" name="clockspot" size="15">
</FORM>
<SCRIPT language="JavaScript">
<!--
startclock();
//-->
</SCRIPT>
</BODY>
If you can amalgamate the two so they appear next to one another on the same line I'd be very grateful. I have absolutely no idea how to do it! The "date" script just has a BODY bit, and the "clock" has a HEAD and BODY part. To edit the script you'll need to cut it from the EDIT option just above this message! Many thanks and good luck?!
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
d = new Array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
);
m = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
);
today = new Date();
day = today.getDate();
year = today.getYear();
if (year < 2000) // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
end = "th";
if (day==1 | | day==21 | | day==31) end="st";
if (day==2 | | day==22) end="nd";
if (day==3 | | day==23) end="rd";
day+=end;
document.write(" ");
document.write(d[today.getDay()]+", "+m[today.getMonth()]+" ");
document.write(day+", " + year);
document.write("</center>");
// End -->
</script>
</BODY>
<!--************************************-->
<HEAD>
<SCRIPT language="JavaScript">
<!--
function startclock()
{
var thetime=new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var AorP=" ";
if (nhours>=12)
AorP="pm.";
else
AorP="am.";
if (nhours>=13)
nhours-=12;
if (nhours==0)
nhours=12;
if (nsecn<10)
nsecn="0"+nsecn;
if (nmins<10)
nmins="0"+nmins;
document.clockform.clockspot.value=nhours+": "+nmins+": "+nsecn+" "+AorP;
setTimeout('startclock()',1000);
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM name="clockform">
<INPUT TYPE="text" name="clockspot" size="15">
</FORM>
<SCRIPT language="JavaScript">
<!--
startclock();
//-->
</SCRIPT>
</BODY>