1. (50 points) Write a javascript function named p1 that creates a picture of a multi-floor brick wall with rows of windows. The sub uses two image files: (1) "window.jpg" which is 100 pixels wide and 150 pixels tall; and (2) a background image "brick3.gif". The form to the left is named f1 and contains two textboxes: (1) Floors (named f); and (2) Windows per Floor (named w). The sub creates a page on-the-fly that contains a <DIV> block with the following style: The value of width is: the number of windows per floor times 100 plus (the number of windows per floor + 1 ) times 100 (i.e., w * 100 + (w + 1 ) * 100 ) Window images (i.e., "window.jpg") have style attributes: "position:absolute"; "Top"; and "Left". Windows are centered vertically on each floor (i.e., 75 pixels from the top and bottom of each floor). Windows are spaced equally horizontally across the floor with 100 pixel spacing between the windows and 100 pixels to left of the first window and 100 pixels to the right of the last window on the floor. Show the javascript for p1. Show NO HTML. |
<XML id="music_xmldata">
<?xml version="1.0"?> <!DOCTYPE my_music [ <!ELEMENT my_music (album+)> <!ELEMENT album (artist,title,year,pub,song+)> <!ELEMENT artist (#PCATA)> <!ELEMENT title (#PCATA)> <!ELEMENT year (#PCATA)> <!ELEMENT pub (#PCATA)> <!ELEMENT song (song_title,time)> <!ELEMENT song_title (#PCDATA)> <!ELEMENT time (#PCDATA)>] <my_music> <album> <artist>Bob Dylan<</artist> <title>Modern Times</title> <year>2006</year> <pub>Sony BMG</pub> <song><song_title>Thunder on the Mountain</song_title> <time>5:50></time></song> <song><song_title>Spirit on the Water</song_title> <time>7:42></time></song> <song><song_title>Rollin and Tumblin</song_title> <time>6:01></time></song> ...lotsa lines omitted... </album><album>
...lotsa lines omitted... <song><song_title>Po Boy</song_title>
|
2. (50 points) My music inventory is stored in XML and is embedded in an HTML page with an XML tag with id=music_xmldata (the DTD and a portion of the XML data are shown to the left). When this button is clicked, a javascript function named p2 is called. This function produces a new page on-the-fly which is a table showing my entire music inventory in the format shown below:
the artist is root.childNodes(i).childNodes(0).text; the title is root.childNodes(i).childNodes(1).text; the pub is root.childNodes(i).childNodes(2).text; the year is root.childNodes(i).childNodes(3).text; where i is the album number. The number of albums is root.childNodes.length. root.childNodes(i).childNodes(j).childNodes(0).text is the song's title; root.childNodes(i).childNodes(j).childNodes(1).text is the song's play time, where j is the song; j starts at 4 and continues through all songs on the album, so long as j < root.childNodes(i).childNodes.length. Show the javascript for p2. Show NO HTML. Show NO XML. |