I cannot to get over a simple noobie hurdle

(Randy Meinert) #1

This code from arcLab presents a simple date & time on a page:

<p>Date/Time: <span id="datetime"></span></p> //put on the page
<script>  //put in the header
var dt = new Date();
document.getElementById("datetime").innerHTML = dt.toLocaleString();

But, of course, it doesn’t work:

(Jannis from inStacks Software) #2

If you are able to publish this page, it makes it easier to check what’s wrong. I guess you entered the HTML
part in a wrong way.

(scott williams) #4

What I was going to say in the last post, I couldn’t edit for some reason…

Try removing the script tags and putting the js in the JavaScript area, put the html bit in wherever you want the date to show up.

(Jannis from inStacks Software) #5

You are also able to put the whole content in the HTML Stack, just as is. You don’t have to separate it into Stacks page and header area.

(Randy Meinert) #6

Thanks for your input. This should be “stupid” simple. I grabbed the code from https://www.arclab.com/en/kb/htmlcss/display-date-time-javascript-php-ssi.html

I simply brought a rudimentary html stack onto a new stacks page, pasted the code (above), then put the script into the header.

I can’t publish the page right now. I re-up’d with GoDaddy for my sites–and trying to save money, the tech had me migrate my websites to a new directory structure. I think something isn’t set right, but I think it’s on his end.

(Randy Meinert) #7

I’d actually put the script in the header area. I moved it to the javascript area. No change.

(Jannis from inStacks Software) #8

Put all together into the HTML stack.

(scott williams) #9

Did you get rid of the <script> and </script>

(Randy Meinert) #10

Your solution worked. Now, here’s the thing: is this approach the “right approach” long term for things of this nature?

(Randy Meinert) #11

THanks for the input. I tried getting rid of the tags - no change.

(Jannis from inStacks Software) #12

That depends on the code. In that case, the JS Code had to be “below” the HTML code.

If you rewrite the JS code, it will work in header also.

(Randy Meinert) #13

Thanks very much for your help.

(system) #14

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.