DISC 3371 Final Full Name____________________________________________________________
Parks Fall 2004 Userid: TMP____________ Last 4 SSN_________________
The Family
 1. Show All Folks
 2. Show Only Folks With Pics
 3. Show All Folks With This String  
     
1. (50 points) Assume a page contains a frameset composed of two columns. The right frame contains only a DIV block with id="fr". The left frame contains the menu as shown in the gray area to the left and a vbscript sub named p1. The menu contains three links:
        the 1st link ("Show All...") contains onClick="p1(1)";
        the 2nd link ("Show...With Pics") contains onClick="p1(2)";
        the 3rd link ("Show All...String")  contains onClick="p1(3)".
The textbox is named w in a form named pform.
When the user clicks a link, the sub p1 displays a table in the right frame. If the user clicks:
  • the first link, the table has five columns, the person's: (1) lastname, (2) firstname, (3) middle name, (4) birth year and (5) death year. The table has 421 rows.
  • the second link, the table has six columns, the person's: (1) lastname, (2) firstname, (3) middle name, (4) birth year, (5) death year and (6) the person's image. The table only has rows for the persons with an image. Display the image NOT the name of the image.
  • the third link, the table has five columns, the person's: (1) lastname, (2) firstname, (3) middle name, (4) birth year, and (5) death year. The table only has rows for persons that contain the search string (the value of the textbox named w) anywhere in the first five fields.
  • The data for the individuals is stored in an global array named p and has 421 elements each containing a person's string data as shown above (not all 421 elements are shown). Each string has seven pieces data separated by commas: (1) Last Name; (2) First Name (may contain two words); (3) Middle Name (may one word, two words, or "?"); (4) Birth Year (may be "?"); (5) Death Year (may be "?"); (6) one character (either "Y" or "N") to indicate if there is an image file; (7) the name of the image file of this person if the previous column is "Y" otherwise a "?".
    (a) Write the vbscript sub named p1. Show no HTML for the frameset or frames.
    (b) Write and use another vbscript sub named vsplitter to split up a person's string into seven parts. This sub will be called from p1 when the detailed information for a person is desired from the array p. In p1 pass only person's array location (i.e., row number) like this:
        call vsplitter(row_num)
    The sub vsplitter uses the person's string (located by row_num ) and splits it into seven parts. vsplitter assigns the resulting seven strings to the globally defined variables: lastname, firstname, middlename, byear, dyear, has_image, and image_name. These global values are then used by the sub p1 to create the table elements for display.
    Click here for the working answer page

     4. Show XML
     
    2. (50 points) Assume there is a fourth link on the menu described above. The link (shown to the left) would contain onClick="pxml()". You are to write the javascript function pxml that takes the data contained in the global array p (shown below to the left) and displays an XML representation of the data in the right frame.
    Make up your own tag names. There should be: one set of outside tags; an outside tag pair for each person that contains the seven detail tags with the appropriate content. (Note: in order to display the tags correctly in HTML you must use "&lt;" instead of "<" and "&gt;" instead of ">")
    This task will require the javascript function pxml to perform the string splitting processs the same way as the one described above to break the person's string up into seven different pieces. You can either: write an additional function (call it jsplitter if you do) or you can perform the splitting task in pxml. Write only the javascript for pxml (and jsplitter if you use a javascript function).
    Click here for the working answer page