MIS 3371 -- Spring 2009 -- Midterm -- Parks -- ANSWERS

                         
                         
DESIGN A WINDOW
  • Border Color:
    Black   Blue   Green  

  • Border size in pixels

  • Pane Height in pixels
  • Pane Width : in pixels

  • Num. of Panes horizontally
  • Num. of Panes vertically
 1. (50 points) The HTML page shown to the left provides several HTML objects that will be used to design a window with mutiple window panes. The image of the window is created using an HTML table. The page has:
  1. a form named f1
  2. three radio buttons that are used to determine the bordercolor of the window
  3. a textbox named b that specifies the width of the border in pixels
  4. two textboxes that determine the size of each window pane in pixels
    the height of each pane is in a textbox named ptall
    the width of each pane is in a textbox named pwide
  5. two textboxes that determine the number of window panes in each window
    the number of panes in the horizontal direction is in a textbox named nh
    the number of panes in the vertical direction is in a textbox named nv
  6. a button labelled "GO" that when clicked calls the vbscript sub named p1
The vbscript sub p1 creates a page on-the-fly that:
  1. use the following <body> tag: <body background='brick3.gif'>
  2. The page contains a centered table with a border equal to the value of textbox b (called "Border Size" to the left)
  3. the table has a bordercolor equal to the color specified by the chosen radio button
  4. the table has nv rows ("Num. of Panes Vertically")
  5. each row of the table has nh cells ("Num. of Panes Horizontally")
  6. each cell has an image named "white1x1.gif" with height equal to the value of the textbox ptall and width equal to the value of the textbox pwide (i.e., "Pane Height" and "Pane Width", respectively)
Show NO HTML for the page to the left. Shown only the vbscript code for the sub named p1. DO NOT edit the data.
 

THE ALAMO DEFENDERS

 2. (50 points) The list of the 193 known defenders of the Alamo (e.g., see this) is shown in a textarea named ta to the left. This textarea is in a form named f2. When the button labeled "GO" at the botton of the textarea is clicked the javascript function p2( ) is executed. The textarea ta contains for each of the 193 defenders their:
  1. Last Name followed by a comma
  2. First and Middle Name(s) followed by a comma
  3. Place of Birth followed by a comma
So there are 193 entries -- each with 3 commas. There are exactly 30 different birth places in this list. The names of these thirty birthplaces are stored in an array named bp, (e.g., bp[0]="Texas", bp[1]="Virginia"; bp[2]="Vermont", etc.). The bp array is available in the function p2. (Do not write or create the contents of the array bp -- assume it is already in the function and all thirty values have been defined). The javascript function p2 should:
  1. retrieve the contents of the textarea ta and store it in a string named a.
  2. split the string a using the comma into an array named n -- there will be 579 elements in n (i.e., 3 times 193).
  3. create another array named bpcount that has 30 elements -- these 30 elements will be used to count the number of occurences of each birthplace in the array n.
  4. initialize the elements of the array bpcount to zero.
  5. loop through the array n examining only the birthplace elements
    (i.e., every third element -- n[2], n[5], n[8], n[11],...etc.)
  6. find each birthplace in the bp array and increment the corresponding location in bpcount by 1.
    (i.e., for each birthplace n[2], n[5], n[7], etc., search through the entire bp array and find the location of the birthplace in bp, then add 1 to the corrsponding location in bpcount
  7. In the DIV block with id="z" (shown below) write:
      (a) the 30 birthplaces (bp) and counts (bpcount) (separated by a <br> tag)
      (b) the birthplace with the largest count

    This is the DIV block with id="z"

    Show NO HTML. Show ONLY the javascript code for p2.