B
Ben
Hi all,
I'm trying to write inside a table cell from external javascript but
am not successful. When I insert inside a form within <td...>, it
works but does not work for normal table cell. My codes are as
follows; please read comments on the code:
index.html
----------
<html>
<head>
<title>Hello World</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript"
src="jatest.js"></script>
</head>
<body onLoad="startclock()">
<center>
<table width="100%" height="431" border="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="148" height="23"> </td>
<td width="346"> </td>
<td id="date" width="104" valign="top"><div align="right">
/*****************************************************/
/*** I WANT TO CALL date() FR0M EXTERNAL FILE HERE ***/
/*********************** HOW??? **********************/
/*****************************************************/
</div></td>
<td width="148"> <div align="right"> </div></td>
<tr>
<td width="148" height="40"> </td>
<td> </td>
<td valign="top"> <div align="right">
<form name="clock">
<input align="right" border="0" type="text" name="face"
size=13 readonly="true">
</form>
</div></td>
<td width="148"> <div align="right"></div></td>
</tr>
</table>
</center>
</body>
</html>
jatest.js
----------
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
document.clock.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function startclock() {
stopclock();
showtime();
}
function date() {
var mydate=new Date()
var day=mydate.getDay()
var mydate=new Date()
var year=mydate.getFullYear()
var month=mydate.getMonth()
var daym=mydate.getDate()
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday",
"Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June"
,"July","August","September","October","November","December")
document.date.write(dayarray[day]+", ")
document.date.write(montharray[month]+" "+daym+", "+year) 
}
Hope some of you can help me...
Thanx
Ben
I'm trying to write inside a table cell from external javascript but
am not successful. When I insert inside a form within <td...>, it
works but does not work for normal table cell. My codes are as
follows; please read comments on the code:
index.html
----------
<html>
<head>
<title>Hello World</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript"
src="jatest.js"></script>
</head>
<body onLoad="startclock()">
<center>
<table width="100%" height="431" border="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="148" height="23"> </td>
<td width="346"> </td>
<td id="date" width="104" valign="top"><div align="right">
/*****************************************************/
/*** I WANT TO CALL date() FR0M EXTERNAL FILE HERE ***/
/*********************** HOW??? **********************/
/*****************************************************/
</div></td>
<td width="148"> <div align="right"> </div></td>
<tr>
<td width="148" height="40"> </td>
<td> </td>
<td valign="top"> <div align="right">
<form name="clock">
<input align="right" border="0" type="text" name="face"
size=13 readonly="true">
</form>
</div></td>
<td width="148"> <div align="right"></div></td>
</tr>
</table>
</center>
</body>
</html>
jatest.js
----------
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
document.clock.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function startclock() {
stopclock();
showtime();
}
function date() {
var mydate=new Date()
var day=mydate.getDay()
var mydate=new Date()
var year=mydate.getFullYear()
var month=mydate.getMonth()
var daym=mydate.getDate()
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday",
"Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June"
,"July","August","September","October","November","December")
document.date.write(dayarray[day]+", ")
document.date.write(montharray[month]+" "+daym+", "+year) 
}
Hope some of you can help me...
Thanx
Ben