B
barry
If The script below is exeuted from the onload="startit()" in the body tag everything works fine but when I remove the onload and try to execute by using the attributes.add from within the Page_Load the window.setInterval will not execute - there is no message but the timer never takes off. I put an alert in the startit() and it did appear so the attributes.add is working ok.
Would appreciate any help
thanks
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.Button3.Attributes.Add("onClick", "startit()")
End Sub
<SCRIPT>
function startit() {
window.setInterval("updateTime()",1000);
}
var seconds=0;
function updateTime() {
// seconds++;
var timeNow = new Date();
var hours = timeNow.getHours();
var minutes = timeNow.getMinutes();
var seconds = timeNow.getSeconds();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue = ((timeValue <10)? "0":"") + timeValue
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
document.getElementById("time").innerHTML = timeValue;
}
</SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout" onload="startit()">
<h1>Sample Document</h1>
<h3>You have been here <b id="time">0</b> seconds.
</h3>
Would appreciate any help
thanks
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.Button3.Attributes.Add("onClick", "startit()")
End Sub
<SCRIPT>
function startit() {
window.setInterval("updateTime()",1000);
}
var seconds=0;
function updateTime() {
// seconds++;
var timeNow = new Date();
var hours = timeNow.getHours();
var minutes = timeNow.getMinutes();
var seconds = timeNow.getSeconds();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue = ((timeValue <10)? "0":"") + timeValue
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
document.getElementById("time").innerHTML = timeValue;
}
</SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout" onload="startit()">
<h1>Sample Document</h1>
<h3>You have been here <b id="time">0</b> seconds.
</h3>