Current Time process on a webpagehttp://forums.asp.net/t/1773521.aspx/1?Current+Time+process+on+a+webpageFri, 24 Feb 2012 17:21:41 -050017735214849733http://forums.asp.net/p/1773521/4849733.aspx/1?Current+Time+process+on+a+webpageCurrent Time process on a webpage <p>I have another issue that came up due to fixing an issue with Google Chrome. I have a checkbox list that is connected to my database. Whenever the user would hit the BACK button in Google Chrome ONLY the checkboxes that were selected would still be clicked. I have that issue resolved, but it has caused my 'current time' code to not work and not update every second. Any ideas how to fix this? I might just have to decide to keep either the time feature or go with the code that fixes the google chrome issue.</p> <p>Code:</p> <p></p> <pre class="prettyprint">var dayarray = new Array(&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;) var montharray = new Array(&quot;January&quot;, &quot;February&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;, &quot;June&quot;, &quot;July&quot;, &quot;August&quot;, &quot;September&quot;, &quot;October&quot;, &quot;November&quot;, &quot;December&quot;) function getthedate() { var mydate = new Date() var year = mydate.getYear() if (year &lt; 1000) year &#43;= 1900 var day = mydate.getDay() var month = mydate.getMonth() var daym = mydate.getDate() if (daym &lt; 10) daym = &quot;0&quot; &#43; daym var hours = mydate.getHours() var minutes = mydate.getMinutes() var seconds = mydate.getSeconds() var dn = &quot;&quot; if (hours &gt;= 12) dn = &quot;PM&quot; else dn = &quot;AM&quot; if (hours &gt; 12) { hours = hours - 12 } if (hours == 0) hours = 12 if (minutes &lt;= 9) minutes = &quot;0&quot; &#43; minutes if (seconds &lt;= 9) seconds = &quot;0&quot; &#43; seconds //Hire change font size // var cdate = &quot;Current Time: &quot; &#43; dayarray[day] &#43; &quot;, &quot; &#43; montharray[month] &#43; &quot; &quot; &#43; daym &#43; &quot;, &quot; &#43; year &#43; &quot; &quot; &#43; hours &#43; &quot;:&quot; &#43; minutes &#43; &quot;:&quot; &#43; seconds &#43; &quot; &quot; &#43; dn &#43; &quot; &quot; if (document.all) document.all.clock.innerHTML = cdate else if (document.getElementById) { document.getElementById(&quot;clock&quot;).innerHTML = cdate } else { document.write(cdate) } } if (!document.all &amp;&amp; !document.getElementById) getthedate() function goforit() { if (document.all || document.getElementById) setInterval(&quot;getthedate()&quot;, 1000) } function reset_main() { // alert('asdf'); document.getElementById(&quot;form1&quot;).reset(); getthedate(); } HTML Code: &lt;body onload=&quot;reset_main()&quot; &gt;</pre> 2012-02-24T16:22:13-05:004849736http://forums.asp.net/p/1773521/4849736.aspx/1?Re+Current+Time+process+on+a+webpageRe: Current Time process on a webpage <p>All the HTML code:</p> <pre class="prettyprint">&lt;body onload=&quot;reset_main()&quot; &gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot; &gt; &lt;span id=&quot;clock&quot;&gt;&lt;/span&gt;</pre> 2012-02-24T16:22:41-05:004849738http://forums.asp.net/p/1773521/4849738.aspx/1?Re+Current+Time+process+on+a+webpageRe: Current Time process on a webpage <p>The code:&nbsp;</p> <pre class="prettyprint">document.getElementById(&quot;form1&quot;).reset();</pre> <pre class="prettyprint"><span class="pun">Is what fixes the google chrome portion in my reset_main routine</span></pre> 2012-02-24T16:23:21-05:004849764http://forums.asp.net/p/1773521/4849764.aspx/1?Re+Current+Time+process+on+a+webpageRe: Current Time process on a webpage <p>Thanks for creating new thread in HTML and JS section. Where do you call the 'current time' method? try resetting only the checkbox then instead of restting whole form:</p> <pre class="prettyprint">document.getElementById(&quot;checkboxList1&quot;).reset();</pre> <p></p> 2012-02-24T16:44:23-05:004849794http://forums.asp.net/p/1773521/4849794.aspx/1?Re+Current+Time+process+on+a+webpageRe: Current Time process on a webpage <p>I figured it out. When I added the code you helped me with, I forgot to call the routine that will set the interval every second. That code was never called, so the time would show up from the start and whenever the form was reset etc.</p> <p>Changed the below:&nbsp;</p> <pre class="prettyprint">function reset_main() { // alert('asdf'); document.getElementById(&quot;form1&quot;).reset(); getthedate(); }</pre> <pre class="prettyprint"><span class="pun"><br /></span></pre> <pre class="prettyprint"><span class="pun">TO:</span></pre> <pre class="prettyprint"><span class="kwd">function</span><span class="pln"> reset_main</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br />&nbsp; &nbsp; </span><span class="com">// &nbsp;alert('asdf');</span><span class="pln"><br />&nbsp; &nbsp; document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">"form1"</span><span class="pun">).</span><span class="pln">reset</span><span class="pun">();</span><span class="pln"><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; goforit();</span><span class="pln"><br /></span><span class="pun">}</span></pre> <pre class="prettyprint"><span class="pun"><br /></span></pre> <pre class="prettyprint"><span class="pun"><br /></span></pre> 2012-02-24T17:03:20-05:004849799http://forums.asp.net/p/1773521/4849799.aspx/1?Re+Current+Time+process+on+a+webpageRe: Current Time process on a webpage <p>Glad you solved!!</p> 2012-02-24T17:06:50-05:004849822http://forums.asp.net/p/1773521/4849822.aspx/1?Re+Current+Time+process+on+a+webpageRe: Current Time process on a webpage <p>haha yep! Thanks agian for the help.&nbsp;</p> 2012-02-24T17:21:41-05:00