tutorial function error

D

DEEP 3z

Im currently learning JavaScript and im doing a tutorial from a magazine....
which doesnt work :/
Through elimination this is the code thats causing a problem... apparently
the browser is expecting a ; somewhere

funtion myupdate()
{
setTimeout("myupdate();" ,100);
if(mystate=="start")
{
mynow = new Date();
mywatch = mynow.getTime() - mystarted.getTime();
document.myform.mytime.value = mywatch/1000;
}
}

This is being called during onLoad as follows:
<BODY onLoad="myreset(); myupdate();">

If i remove the myupdate funtion declaration and call all works fine.
Any ideas?
Thanks
 
D

DEEP 3z

Heres the body section in full, might be an issue with myreset but i dont
get that impression

<BODY onLoad="myreset(); myupdate();">
<SCRIPT>
function myreset() {
mystate = "stop";
mywatch = 0;
document.myform.mytime.value = mywatch/1000;
}

function mystartstop() {
if (mystate == "stop") {
mystate = "start";
mystarted = new Date();
mystarted.setTime(mystarted.getTime() - mywatch);
} else {
mystate = "stop";
mystopped = new Date();
mywatch = mystopped.getTime() - mystarted.getTime();
document.myform.mytime.value = mywatch/1000;}
}

function myupdate() {
setTimeout("myupdate();", 100);
if (mystate == "start"){
mynow = new Date();
mywatch = mynow.getTime() - mystarted.getTime();
document.myform.mytime.value = mywatch/1000;}
}
</SCRIPT>

<CENTER>
<FORM NAME="myform">
Time:<INPUT TYPE="TEXT" Name="mytime">
<INPUT TYPE="BUTTON" VALUE="Start/Stop" onClick="mystartstop()">
<INPUT TYPE="BUTTON" VALUE="Reset" onClick="myreset()">
</FORM>
</CENTER>
</BODY>
 
D

DEEP 3z

Weird its working for me now, I thought it should have in the 1st place, I
must have made an error in copying it (i tried creating it bit by bit to
build understanding) but im sure i copied and pasted at one point as i did
for the newsgroup.

Anyway apologetic thanks for your slightly wasted time all :/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top