View Single Post
Old 12-13-2005, 08:49 PM   #1 (permalink)
TheProf
Crazy
 
[Javascript] Is this even remotely correct?

Hello.

I am trying to get a website to display a specific thing based on the hour of the day. I *think* this works (I'm a C person myself) but when I drop it into the CMS I'm using it displays nothing.

Thoughts?

Code:
<script Language="JavaScript">
 
var today = new Date();
var hours = today.getHours();

var readings = 0;

switch (hours) 
{
case 0: 
readings = 7;
  break
case 1: 
readings = 7;
  break
case 2: 
readings = 7;
  break
case 3: 
readings = 7;
  break
case 4: 
readings = 7;
  break
case 5: 
readings = 7;
  break
case 6: 
readings = 1;
  break
case 7: 
readings = 1;
  break
case 8: 
readings = 1;
  break
case 9: 
readings = 2;
  break
case 10: 
readings = 2;
  break
case 11: 
readings = 2;
  break
case 12: 
readings = 3;
  break
case 13: 
readings = 3;
  break
case 14: 
readings = 3;
  break
case 15: 
readings = 4;
  break
case 16: 
readings = 4;
  break
case 17: 
readings = 4;
  break
case 18: 
readings = 5;
  break
case 19: 
readings = 5;
  break
case 20: 
readings = 5;
  break
case 21: 
readings = 6;
  break
case 22: 
readings = 6;
  break
case 23: 
readings = 6;
  break
}

AgpeyaHours = new Array(8);
 
AgpeyaHours[1]="Prime"
AgpeyaHours[2]="Terce"
AgpeyaHours[3]="Sext"
AgpeyaHours[4]="None"
AgpeyaHours[5]="Vespers"
AgpeyaHours[6]="Compline"
AgpeyaHours[7]="Midnight"

document.write(AgpeyaHours[readings]);
</script>
TheProf is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76