MIS 3371 -- PARKS -- MIDTERM - SPRING 2013 -- ANSWERS

Money Magazine's 2012 Top 100 Places Work
1. (50 points) The textarea (named tp) shown to the left contains data on the "2012 Top 100 Places to Work" in a form named f1. The textarea has 100 companies each with the following data:
    (a) ranking (from 1 to 100) followed by a semicolon;
    (b) company name followed by a semicolon;
    (c) annual % growth followed by a semicolon;
    (d) number of employees followed by a "*" (except the last one)
When this button is clicked a vbscript sub named p1 is executed. This sub:
  1. creates a string that contains a 100 row table each with four columns: (1) rank; (2) company name; (3) % growth; (4) number of employees.
  2. additionally, the "name of the company" with the largest "annual % growth" is shown followed by its "annual % growth" on a single line.
    CAUTION #1: where growth data for a company is NOT AVAILABLE a value of "N.A." is shown. Skip these companies when determining the largest "annual % growth"
    CAUTION #2: each "annual % growth" string ends with a "%" sign. This "%" must be removed AND the result converted to an integer before a comparison can be made
  3. Place the output in the DIV block with id="p1_out"
This is the DIV block with id="p1_out"
Write only the vbscript for p1. Show NO HTML. The data is from: http://money.cnn.com/magazines/fortune/best-companies/2012/full_list/

  1. String To Search For:
  2. Results:
This is the DIV block with id="p2_out"
2. (50 points) The entire text of Franz Kafka's 1915 story "Metamorphosis" is stored in a textarea named ta2 in a form named f2 (as partially shown to the left). Each line of text contains: a number (an integer followed by a period and a space); then the string of text; and then a "*" at the end of the line (except the last line). A textbox for the user to enter a search string is shown below the textarea. This textbox is named sf and contains the text the user wishes to find in the body of the story. When button labelled "SEARCH" is clicked:
  1. the textarea ta2 is retrieved by the javascript function named p2
  2. the text is then split into an array using the "*" character ("*" does NOT appear anywhere in the text of the story)
  3. the function then searches EACH text row (there are 1,945 rows) for the occurence of the sf string
  4. when found, the entire text row is displayed with the sf string replaced with this:
    <span style='color:red;'>[the value of sf string]</span>
    (i.e., display the sf portion of the text in red)
  5. show the entire revised row text for EACH row where sf was found in the DIV block with id="p2_out". Found rows are separated by a <br> tag. Show the number found OR if none were found, show "NONE FOUND".
Story from the Guttenberg Project: http://www.gutenberg.org/ebooks/5200
Notes:
Only highlight the FIRST occurence of the sf value in each row.
Disregard all others in the row. (i.e., don't search for more one occurence of sf).
Assume the search is case-sensitive.
Show only the javascript for p2. Show NO HTML.