MIS 3371 -- PARKS -- MIDTERM ANSWERS - SPRING 2014

1. (50 points) The Top 100 Learning Tools of 2013 (http://c4lpt.co.uk/top100tools/) are shown to the left in a textarea named ta contained in a form named f1. The data represents a poll of 500 learning professionals. Each of the entries contain:
    1. rank_this_yr followed by a comma
    2. website followed by a comma
    3. tool_description followed by a comma
    4. rank_change_from_last_yr followed by a "*" (except the last one)
        values of rank_change_from_last_yr can be:
        "same" -- rank_this_yr is same as last year
        "new" -- never been on the list before
        "back" -- on the list before -- but not last year
        "up": follow by an integer (on the list last year and rose integer ranks)
        "down": follow by an integer (on the list last year and dropped integer ranks)
When the user clicks this "p1" button , a vbscript sub named "p1" is executed. This sub:
1. retrieves the value of ta
2. creates a 100 row by 4 column table. Each row has:
    column 1 contains the rank_this_yr
    column 2 contains the website
    column 3 contains the tool_description
    column 4 if rank_change_from_last_yr contains the "up" or "down" values,
    calculate and display the "rank_last_yr".
    e.g., if rank_change_from_last_yr="up by 2" and rank_this_yr=7, then rank_last_yr= 7 + 2 = 9
    e.g., if rank_change_from_last_yr="down by 2" and rank_this_yr=7, then rank_last_yr= 7 - 2 = 5
    if the rank_change_from_last_yr is "same", copy the value for column 4 from column 1
    if the rank_change_from_last_yr is "back" or "new", display the value in the 4th cell of the row

This is the DIV with id="p1out"

Show NO HTML.
Do NOT write the table heading row as shown at the top of the table in the answer.
Write only the vbscript for p1.

Create a month calendar

  Year

  Month
            [0=Jan, 1=Feb, 2=Mar, ... 11=Dec]

  

This is the DIV block with id="p2out"

2. (50 points) Write the javascript function p2 that creates an HTML table for the month and year specified by the two text boxes in a form named f2 shown to the left. The user enters: (1) the year in the text box named yr and (2) the month in a text box named mon. The calendar will have 8 rows:
 row 1. the month name and then the year centered in the row (see month names array below)
 row 2. seven cells containing the day names (see the day names array below)
 row 3-8. the numbered days of the month

To find the values you need for specified month and year use this:
   var new_date = new Date (user-entered-year-value,user-entered-month-value,1); then
Then, to find the first_day of the month use:
   first_day = new_date.getDay(1); [NOTE: first_day = 0 if Sun, 1 if Mon, 2 if Tue,...,6 if Sat]
To find the number of days in the specified month and year use:
   numdays= new Date(user-entered-year-value,user-entered-month-value + 1 , 0).getDate();

1. Beginning in the third row, count the table cells as you progress -- call this variable cellnum
2. Place a blank in each cell until you get to the first_day of the month,
    then start counting and displaying the days -- use the variable daynum
3. Place the daynum in all cells until daynum > numdays, then place a blank in all the remaining cells.

Caution: in some months/years, the eighth row will not be needed.
Check the last row to be sure there are days yet to be displayed.

Assume two arrays are defined for you as follows:

var mname=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var dname = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

Show NO HTML. Show only the javascript for p2.