Skip to main content

I can not get result after calling JavaScript function



I am working with Javascript StopWatch in C# web Aplication. But I don't get output from javascript. Below is my code.







<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<script type="text/javascript" language="JavaScript">

var state = 0;

function startstop() {

if (state == 0) {

state = 1;

then = new Date();

then.setTime(then.getTime() - ms);

} else {

state = 0;

now = new Date();

ms = now.getTime() - then.getTime();

document.stpw.time.value = ms;

}

}

function swreset() {

state = 0;

ms = 0;

document.stpw.time.value = ms;

}

function display() {

setTimeout("display();", 50);

if (state == 1) {now = new Date();

ms = now.getTime() - then.getTime();

document.stpw.time.value = ms;

}

}

</script>

</head>

<body onload="display()">

<form id="form1" runat="server">

<div>

Time:

<input type="text" name="time"/>

<input type="button" name="ssbutton" value="Start/Stop" onclick="javascript:startstop()"/>

<input type="button" name="reset" value="Reset" onclick="javascript:swreset()"/>



</div>

</form>

</body>

</html>







I am new with javascript ,Where I am doing mistake?? Thank You...


Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?