0

guys i am new to java scripts and these days iam following some tutorials on w3school and lynda.
i have a big problum on classes on Jscripts.

this is my code

<html>
<body>
<script type="text/javascript">
//Write a "Good morning" greeting if
//the time is less than 10

var d=new Date();
var time=d.getHours();

if (time<10)
  {
  document.write("<b>Good morning</b>");
  }
</script>

this code is working fine and if i chang that "var d=new Date();" lines Date() in to "date()" the code is not working .
and again in next line "var time=d.getHours();" getHours() in to "gethours()" then again the code get wrong . so it means the java scripts have its own classes.

3
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by chathuD
0

and i have to remember all the prefix classes on javascripts by heart

0

You are correct:

The function

getHours()

Is not the same function as

gethours()

Due to the fact that function names are case-sensitive.

It is not so hard learning the standard classes. It is easier if you learn it in practice, for example making your own clock.

~G

0

most would do that in php/asp so as not to transfer as much information and keep the page the user sees (eg view source) simpler

<?php $today=getdate();
if($today['hours'] > 17) { $display='evening';} 
elseif($today['hours'] > 11) { $display='afternoon';} 
else $display = "morning"; 
echo 'Good '.$display;?>

view source Good morning

datetoday = new Date(); 
thehour = datetoday.getHours();
if (thehour > 17) display = "evening";
else if (thehour >11) display = "afternoon";
else display = "morning";
document.write("Good " + display );

View source <script type='text/javascript'>datetoday = new Date();thehour = datetoday.getHours();if (thehour > 17) display = "evening";else if (thehour >11) display = "afternoon";else display = "morning";document.write("Good " + display );</script> javascript is tediously case sensistive

Edited by almostbob: n/a

0

ooooooooh....case sensitive .......then is their any plce where i can see or get (actually study ) all the function s on Jscript.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.