Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to set value of the property 'innerHTML': object is null or undefined
    primarykey
    data
    text
    <p>When I try to display the result of these to functions in my page it returns an error. Error: Unable to set value of the property 'innerHTML': object is null or undefined</p> <p>The scripts work, they are not mine. I got them from working examples i found online.</p> <p>EDITEDL: I did change it, but still getting the same error</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; #header { font-size: 5em; } &lt;/style&gt; &lt;script type="text/javascript"&gt; function updateclock() { var currentTime = new Date(); var currentHours = currentTime.getHours(); var currentMinutes = currentTime.getMinutes(); var currentSeconds = currentTime.getSeconds(); // Pad the minutes and seconds with leading zeros, if required currentMinutes = (currentMinutes &lt; 10 ? "0" : "") + currentMinutes; currentSeconds = (currentSeconds &lt; 10 ? "0" : "") + currentSeconds; // Choose either "AM" or "PM" as appropriate var timeOfDay = (currentHours &lt; 12) ? "AM" : "PM"; // Convert the hours component to 12-hour format if needed currentHours = (currentHours &gt; 12) ? currentHours - 12 : currentHours; // Convert an hours component of "0" to "12" currentHours = (currentHours == 0) ? 12 : currentHours; // Update the time display document.getElementById("clock").innerHTML = (currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay); } function updatedate() { var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var d = new Date(); var curr_day = d.getDay(); var curr_date = d.getDate(); var sup = ""; if (curr_date == 1 || curr_date == 21 || curr_date == 31) { sup = "st"; } else if (curr_date == 2 || curr_date == 22) { sup = "nd"; } else if (curr_date == 3 || curr_date == 23) { sup = "rd"; } else { sup = "th"; } var curr_month = d.getMonth(); var curr_year = d.getFullYear(); document.getElementById("date").innerHTML = (d_names[curr_day] + " " + curr_date + "&lt;SUP&gt;" + sup + "&lt;/SUP&gt; " + m_names[curr_month] + " " + curr_year); } updateclock(); setInterval(updateclock, 1000); updatedate(); setInterval(updatedate, 1000); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td style="text-align=center" id =header&gt; &lt;/td&gt; &lt;td&gt; &lt;span id="date"&gt;&amp;nbsp;&lt;/span&gt; &lt;span id="clock"&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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.
    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