Help with website

Hello, my team is working on the website and were trying to do some java script but could not get it to work could someone tell me what is wrong with this simple script.

<html>
<head>

</head>
<body>

<h1>Team #</h1>
<p id=“demo”></p>

<button type=“button” onclick=“displayDate()”>Display Date</button>
<script type=“text/javascript”>

var a =1;
function displayDate()
{
a=a+2;
}

if (a==1)
{
document.getElementById(“demo”).innerHTML=“Hello”;
}
else
{
document.getElementById(“demo”).innerHTML=“GoodBye”;
}

</script>

</body>
</html>

Add a set of curly braces around the code you want in the function e.g.


var a =1;
function displayDate()
{
	a=a+2;
	if (a==1)
	{
		document.getElementById("demo").innerHTML="Hello";
	}
	else
	{
	document.getElementById("demo").innerHTML="GoodBye ";
	}
}

The if statement that changes the innerHTML was not being called when you clicked the button, only the addition part

Make sense?

First of all, you should ALWAYS begin your HTML files with a doctype.

<!DOCTYPE html

Your JavaScript should really be in a separate file that is linked in with something like this before the tag:

<script type="text/javascript" src="js/index.js"></script>

with all your JavaScript being put in the file “index.js” in a “js” subdirectory.

Second of all, I made a little demonstration snippet using JSFiddle, which can be found here: http://jsfiddle.net/ianonavy/cfHpd/

I hope this helps. Continue to post if you have further questions.

Thank you I understand what I did wrong. You were big helps.