Toka
08-10-2003, 09:53 AM
Hi,
I am new to javascript and am working through a tutorial, but I have written a piece of code identical to that in the tutorial but mine dosen't work. I have checked i haven't missed anything and that it is identical.
To all you on here it is a very small, and very simple piece of code. Please could someone put some light on this.
Code1. This works:-
<html>
<body>
<script type="text/javascript">
var d = new Date()
var time = d.getHours()
if (time < 17)
{
document.write("<b>Good morning</b>")
}
</script>
<p>
This example demonstrates the If statement.
</p>
<p>
If the time on your browser is less than 17,
you will get a "Good morning" greeting.
</p>
</body>
</html>
Code2. This dosen't work:-
<html>
<body>
<script type="text/javascript">
var d = new Date()
Var time = d.getHours()
if (time < 17)
{
document.write("<b>Good morning</b>")
}
</script>
<p>
This example demonstrates the If statement.</p>
<p>If the time on your browser is less than 10, you will get a "Good morning" greeting.
</p>
</body>
</html>
Anyone any idea's, or have I just missed something out and am going Blind
Thanks
I am new to javascript and am working through a tutorial, but I have written a piece of code identical to that in the tutorial but mine dosen't work. I have checked i haven't missed anything and that it is identical.
To all you on here it is a very small, and very simple piece of code. Please could someone put some light on this.
Code1. This works:-
<html>
<body>
<script type="text/javascript">
var d = new Date()
var time = d.getHours()
if (time < 17)
{
document.write("<b>Good morning</b>")
}
</script>
<p>
This example demonstrates the If statement.
</p>
<p>
If the time on your browser is less than 17,
you will get a "Good morning" greeting.
</p>
</body>
</html>
Code2. This dosen't work:-
<html>
<body>
<script type="text/javascript">
var d = new Date()
Var time = d.getHours()
if (time < 17)
{
document.write("<b>Good morning</b>")
}
</script>
<p>
This example demonstrates the If statement.</p>
<p>If the time on your browser is less than 10, you will get a "Good morning" greeting.
</p>
</body>
</html>
Anyone any idea's, or have I just missed something out and am going Blind
Thanks