Note that there are some explanatory texts on larger screens.

plurals
  1. POReading the Date from div
    primarykey
    data
    text
    <p>I'm making a web page and I have to make a countdown that read the date from a div (the div read the date from database).</p> <p>When it takes the string, it behaves as it has not read my input date, although it reads the famous "1 january 1970".</p> <p><strong>JavaScript:</strong></p> <pre><code>&lt;script language="JavaScript"&gt; var gcor = new Date(); var dscad = new Date(document.getElementById("caramello")); var difftempo = (dscad - gcor) / 1000; var minuto = 60; var ora = 60 * 60; var giorno = 60 * 60 * 24; var giorest = Math.floor(difftempo / giorno) var orerest = Math.floor((difftempo - giorest * giorno) / ora) var minrest = Math.floor((difftempo - giorest * giorno - orerest * ora) / minuto) var secrest = Math.floor((difftempo - giorest * giorno - orerest * ora - minrest * minuto)) ID = window.setTimeout("update();", 1000); function update() { gcor = new Date(); difftempo = (dscad - gcor) / 1000; minuto = 60; ora = 60 * 60; giorno = 60 * 60 * 24; giorest = Math.floor(difftempo / giorno) orerest = Math.floor((difftempo - giorest * giorno) / ora) minrest = Math.floor((difftempo - giorest * giorno - orerest * ora) / minuto) secrest = Math.floor((difftempo - giorest * giorno - orerest * ora - minrest * minuto)) document.getElementById("Label1").innerText = giorest; if (giorest &lt; 10) { document.getElementById("Label2").innerText = "0" + orerest; } else { document.getElementById("Label2").innerText = orerest; } if (minrest &lt; 10) { document.getElementById("Label3").innerText = "0" + minrest; } else { document.getElementById("Label3").innerText = minrest; } if (secrest &lt; 10) { document.getElementById("Label4").innerText = "0" + secrest; } else { document.getElementById("Label4").innerText = secrest; } ID = window.setTimeout("update();", 1000); } </code></pre> <p>and this is the <strong>html/asp</strong> that is linked with it:</p> <pre><code>&lt;body&gt; &lt;form runat="server"&gt; &lt;div&gt; &lt;div id="caramello" onclick="prova();"&gt;18 july 2013&lt;/div&gt;&lt;br /&gt; &lt;br /&gt; &lt;asp:Label ID="Label6" runat="server" Text="Label"&gt;&lt;/asp:Label&gt; &lt;br /&gt; &lt;asp:Label ID="Label1" runat="server" Text="00"&gt;&lt;/asp:Label&gt;g &lt;asp:Label ID="Label2" runat="server" Text="00"&gt;&lt;/asp:Label&gt;h &lt;asp:Label ID="Label3" runat="server" Text="00"&gt;&lt;/asp:Label&gt;m &lt;asp:Label ID="Label4" runat="server" Text="00"&gt;&lt;/asp:Label&gt;s &lt;/div&gt; &lt;/form&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    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