ANSWERS MIS 3371 - PARKS - MIDTERM - SUMMER 2012

 
 Top 100 Global Franchises
 
1. (50 points) The textarea named t100 (shown to the left) is in a form named f1 that contains the top 100 global franchise rankings. For each franchise there are four pieces of data separated by semicolons. Each franchise is separated from the next one by a "*" character. The format of the four data items for each franchise is: (a) rank followed by a semicolon; (b) company name followed by a semicolon; (c) country followed by a semincolon; and (d) industry category followed by a "*" (except the last one).

There is a button labelled "execute p1", that when clicked executes the javascript function named p1. This function:

  • retrieves tha data from the textarea named t100
  • in a string named os accumulates the HTML to produce a four column table with 100 rows where the columns contain: (1) the rank; (2) company name; (3) country; and (4) industry.
  • for each, franchise, if the county value does NOT equal "USA", set the background color of the table cell to red.
  • count the number of franchises where country equals "USA". Show this count following the table
  • place the output string (i.e., os) in the DIV with id="p1out"

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

    this is DIV with id=p1out

    http://www.franchisedirect.com/top100globalfranchises/rankings/
  • BLUE TWO

     Choose a digit:  0
     1
     2
     3
     4
     5
     6
     7
     8
     9

    2. (50 points) The DIV block shown to the left has id="p2out" and contains 500 random digits separated by single spaces. The ten radio buttons shown below p2out are in a form named f2. The radios are:

    window.document.f2.elements(0);
    window.document.f2.elements(1);
    ...
    window.document.f2.elements(9).

    When the button labelled "execute p2" is clicked, the vbscript sub named p2 is executed. This sub:

  • retrieves the current contents of the p2out DIV block and stores the contents in a variable named dval
  • determines which radio is checked (i.e, which integer has the user chosen with the radio buttons) The value can only the integers 0 through 9.
  • store this integer in the variable named c.
  • replace ALL occurences of c in the string dval with the following string:

    "<font color='red'>"+cstr(c)+"</font>"

  • however, if c is equal to 2, use a blue font instead of red
  • place the revised value of dval into the DIV with id=p2out.

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