Note that there are some explanatory texts on larger screens.

plurals
  1. POI can not get result after calling JavaScript function
    primarykey
    data
    text
    <p>I am working with Javascript StopWatch in C# web Aplication. But I don't get output from javascript. Below is my code.</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;script type="text/javascript" language="JavaScript"&gt; 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; } } &lt;/script&gt; &lt;/head&gt; &lt;body onload="display()"&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; Time: &lt;input type="text" name="time"/&gt; &lt;input type="button" name="ssbutton" value="Start/Stop" onclick="javascript:startstop()"/&gt; &lt;input type="button" name="reset" value="Reset" onclick="javascript:swreset()"/&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I am new with javascript ,Where I am doing mistake?? Thank You...</p> <p><strong>Udate</strong>:Finally I get the errors and solved it. Here is updates solution for someone who want to implement JavaScript Stopwatch in C# Application.</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; var ms = 0; var state = 0; var then; var now; ms = new Date(); 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.getElementById('timeInput').value = ms; } } function swreset() { state = 0; ms = 0; document.getElementById('timeInput').value = ms; } function display() { ms = new Date(); setTimeout("display();", 50); if (state == 1) { now = new Date(); ms = now.getTime()-then.getTime(); document.getElementById('timeInput').value = ms; } } &lt;/script&gt; &lt;/head&gt; &lt;body onload="display()"&gt; &lt;form&gt; Time: &lt;input type="text" name="time" id="timeInput"/&gt; &lt;input type="button" name="ssbutton" value="Start/Stop" onclick="javascript:startstop()"/&gt; &lt;input type="button" name="reset" value="Reset" onclick="javascript:swreset()"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Thanks For All your help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload