MIS 3371 - PARKS - MIDTERM - FALL 2012 -- ANSWERS

 2012 TOP 100 PLACES TO LIVE IN THE US
from CNN Money

1. (50 points) The textarea (named t100) shows CNN Money magazine's Top 100 places to live in the US for 2012. The textarea is in a form named f1. The format of the data in the textarea is:
   • ranking followed by a semicolon;
   • name of the town followed by a semicolon;
   • two character state abbrviation followed by a semicolon;
   • city population followed by an asterisk (*);
So, each town has 4 fields: ranking, name, state and population. Further, there are two arrays available in your code: (1) a 50 element array named s which contains the 50 state abbreviations:
   s = Array ("AK","AL","AR","AS", ... ,"VT","WA","WI","WV","WY");
and (2) a 50 element array named sc which contains 50 zeroes:
   sc = Array (0,0,0,0,0,0, ... ,0,0,0,0,0)
Produce a report by with the following two items:
  1. A 50-row 2-column table that shows for each state the number of towns in that state that appear in the top 100 list. The first column contains the two character state abbreviation and the second column contains the number of towns in that state that appear in the list shown in the textbox named t100.
  2. Following the table, on a single line show the number of states WITHOUT ANY towns in the top 100 list.

The button labelled "Execute p1" (to the left) causes a vbscript sub named p1 to be executed.

This is the DIV block with id="p1_out"

Show NO HTML. Show ONLY the vbscript code for the sub named p1.

Declaration of Independence
Signers by State
2. (50 points) The textarea named ta3 is in a form named f2. The textarea contains list of the signers of the Declaration of Independence arranged by state. The states are separated by the an asterisk (*). A comma follows each state name. Following this comma are: the signer's name, a comma, their portrait image name, and another comma. The last image name in the state is NOT followed by a comma. There is a button labelled "Execute p2" that causes the javascript function p2 to be executed. Write this javascript function that:

   • 1. retrieves the contents of the textarea named ta3
   • 2. creates a 2-row 13-column table that contains:
      (a) a state names in each of the 13 columns of the first row
      (b) the signers from each state in each of the 13 columns of the second row.
            • Each signer's portrait image should be displayed first using this format:

<img src='http://www.ushistory.org/declaration/signers/images/signer image name' width='60'>

            • then place the signer's name underneath the image.
   • 3. Create a new page on-the-fly that displays the table.

Hint: row 1 and row 2 are different tasks. You have to pass through the data twice. Use separate code segments for each row.

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

Portrait images are found at: http://www.ushistory.org/ (by Ole Erekson, Engraver, c1876, Library of Congress)