Can someone please error check my html :)

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
Post Reply
CodeNub
Rank 0 - Newcomer
Posts: 1
Joined: Sun Oct 13, 2013 6:15 am

Can someone please error check my html :)

Post by CodeNub »

Basically, it is a message and it changes automatically everyday, the website this is on is http://www.codepr4ctice.webs.com
This code works I know that much, I got it from a different website (yes legally):

<html>
<body>

<p>Click the button to display a message based on what day it is today.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction()
{
var x;
var d=new Date().getDay();
switch (d)
{
case 6:
   x="Today it's Saturday";
  break;
case 0:
  x="Today it's Sunday";
   break;
default:
   x="Looking forward to the Weekend";
}
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>



Here's my one which won't work and I can't figure out why :(



<html>
<head>
<style type="text/css">
body {font-family:courier;}
p {font-family:courier; font-size:100%;}
h2 {font-family:courier; font-size:100%; text-decoration:underline}
</style>
</head>
<body>

<h2>Time to have some fun!!</h2>

<p>----------------------------------------------</p>

<p>Message Of The Day: <button onclick="myFunction()">CLICK ME!!</button> </p>

<p id="demo"></p>

<script>
function myFunction()
{
var x;
var d=new Date().getDay();
switch (d)
{
case 1:
x="School's started, noooo!"
break;
case 2:
x="Normal day at school."
break;
case 3:
x="Getting in the swing of things."
break;
case 4:
x="Getting tired of school now.."
break;
case 5:
x="Weekend tommorrow! Go away school!"
break;
case 6:
   x="Sport, then alot of sleeping today!";
  break;
case 0:
  x="Rest Rest Rest Rest, school tommorrow...";
   break;
default:
   x="I'll be honest, something's fked up...";
}
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Can someone please error check my html :)

Post by Albert Wiersch »

Hello,

I tried it and it seems to have worked for me. What exactly is it doing or not doing that you think is wrong?
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
Post Reply