MIS 3371 Spring 2011 Midterm Exam Parks

Here the Excel worksheet:

Below is the textarea named ta with the data from the spreadsheet pasted inside.

this is the "p1out" div block
1. (50 points) The textarea shown to the left is named ta and is in a form named p1form. The textarea contains part of an Excel spreadsheet that has been "cut and pasted" into the textarea. Here are some facts about the way Excel stores selected and copied data:
  •  when you select and copy data from an Excel speadsheet, the first item in the string is the data from the first cell, first row. (i.e., it begins with selected data from the upper left-hand corner cell), then...
  •  following the cell data, Excel places a "tab" character (this is the 10th character in the ASCII table, ASCII value = 9). It does this for each cell in the row -- except the last cell in the row where,
  •  Excel places two characters: (1) a "carriage return" (this is the 14th character in the ASCII table, ASCII value=13); and (b) a "line feed" (this is the 11th character in the ASCII table, ASCII value=10). The string looks like this:

    cell data [tab] cell data [tab] ... cell data [carriage return] [line feed]
    cell data [tab] cell data [tab] ... cell data [carriage return] [line feed]
    cell data [tab] cell data [tab] ... cell data [carriage return] [line feed]
    cell data [tab] cell data [tab] ... cell data [carriage return] [line feed]

  • When the user clicks the button labelled "execute p1", a javascript function named p1 is executed. There is a DIV block with id="p1out" shown below the button. The final answer is shown in this DIV block. You are to retrieve the Excel data from the textarea and convert it to an HTML table and display it in the DIV block. The function p1 should:
    1. retrieve the Excel string from the textbox named ta.
    2. remove ALL the "carraige return" characters (ASCII character value = 13) from the string (the ASCII character 13 in javascript is specified by String.fromCharCode(13) )
    3. start an output string named s with: (a) a table tag that specifies a 1 pixel border; (b) a beginning row tag; AND (c) a beginning cell tag
    4. for EVERY character in the textarea, determine its ASCII value (i.e., its location in the ASCII table)
      [Hint: if a character is named fred, then its ASCII value = fred.charCodeAt(0) ]
      1. if the ASCII value equals 9, then in s: (a) end the HTML cell; and (b) start a new HTML cell.
      2. if the ASCII value equals 10, then in s: (a) end the HTML cell; (b) end the HTML row; AND if this is NOT the last character in the string then: (c) start a new HTML row; and (d) start a new HTML cell.
      3. otherwise, add the character to the string s (add the character NOT its ASCII value)
    5. when you are finished, attach the ending HTML table tag to the string s and copy it to the DIV block with id="p1out".
    Show NO HTML, show ONLY the javascript code for the function name p1.
    Fan Forum for the Houston Skateboard Team

    Enter Your Comments Below (200 characters max):

    Your Comments will appear on the page like this:

    This is DIV block with id="fan_out"
    2. (50 points) The textbox shown to the left is named fanbox and is in a form named p2form. After the user enters text, they press the "Preview Your Comments" button to see how their posting to the forum will appear on the page. Clicking button "Preview Your Comments" executes the javascript sub named p2. This function:
    1. retrieves the contents of the textbox named fan_box
    2. examines the text and removes all the following HTML tags:

      <u>, </u>, <i>, </i>, <b>, </b>, <p>, </p>, <br>,

      Assume these nine strings (i.e., "<u>", "</u>", ... , "<br>" ) are stored in an array named tags (Do not write the tags array declaration or initialization -- assume it already exists in p2)

    3. removes any characters after the the 200th from the remaining text (i.e., max of 200 bytes)
    4. examines the text again for any occurence of the word "Crashers" and replaces it with:

      "<font color='#ff0000'>CRASHERS</font>"

    5. displays the resulting text in the DIV block with id="fan_out"
    Show NO HTML. Show only the vbscript code for p2.