Advertisement
Guest User

Untitled

a guest
Nov 16th, 2012
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.60 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta charset="utf-8" />
  5.         <title>Javascript Timetable</title>
  6.         <!-- <link rel="stylesheet" type="text/css" href="../css/css.css"> -->
  7.         <style type="text/css">
  8. #timeTableBody {
  9.     text-align: center;
  10.     line-height: 1.9em;
  11.     font-style: italic;
  12.     font-family: Georgia, "Time New Roman", Times, serif;
  13.     color: #444444;
  14.     border-color: black;
  15.     border-width: 1px;
  16.     border-style: dotted;
  17.     background-color: #a7cece;
  18.     padding: 25px;
  19.     margin: 30px;
  20. }​
  21.         </style>
  22.         <script type="text/javascript">
  23. // attach listener to window.load
  24. window.addEventListener('load', function () {
  25.     document.getElementById('clickme').addEventListener('click', myFunction, false);
  26. }, false);
  27.  
  28. // function definition gets hoisted so after is okay for this example
  29. function myFunction() {
  30.     var x,
  31.         d = document.getElementById('usersDay').value,
  32.         y = parseInt(d);
  33.     switch (y) {
  34.         case 0:
  35.             x=alert("Lectures on day 0? Really?");
  36.             break;
  37.  
  38.         case 1:
  39.             x="On Monday we have: CS1004 Lectures at 11:00 - 12:00 am & 14:00 - 15:00pm | CS1701 Lab at 15:00 - 16:00pm";
  40.             break;
  41.  
  42.         case 2:
  43.             x="On Tuesday we have: CS1701/CS1702 Netball Hall lab from 9:00 - 10:00am | CS1005 Lecture from 10:00 - 11:00 | CS1005 Lab from 11:00 - 12:00 | CS1701 Lecture from 15:00 - 16 :00 | CS1702 Lab from 15:00 - 17:00";
  44.             break;
  45.  
  46.         case 3:
  47.             x="On Wednesday we have: No Lectures (We're Green Group)";
  48.             break;
  49.  
  50.         case 4:
  51.             x="On Thursday we have: CS1703 Lecture from 09:00 - 10:00 | CS1703 Lab from 10:00 - 11:00 | CS1702 Lecture from 14:00 - 15:00";
  52.             break;
  53.  
  54.         case 5:
  55.             x="On Friday we have: No lectures!";
  56.             break;
  57.  
  58.         case 6:
  59.             x="No Lectures/Labs on Saturday";
  60.             break;
  61.  
  62.         case 7:
  63.             x="No Lectures/Labs on Sunday";
  64.             break;
  65.            
  66.         default:
  67.             alert("Please input a number between 1 and 7. 1 for Monday, 2 for Tuesday and so on...");
  68.             break;
  69.     }
  70.     document.getElementById("demo").innerHTML=x;
  71. }
  72.         </script>
  73.     </head>
  74.     <body id="timeTableBody">
  75.         <p>Type in the day of the week in the text box (numbers 1 to 7) and click 'search' to view our timetable on the chosen day</p>
  76.          
  77.         <input type="number" min="1" max="7" id="usersDay" />
  78.         <button id="clickme">search</button>
  79.          
  80.         <p id="demo"></p>
  81.     </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement