1. (50 points) In a form named f1 shown to the left are: four radio buttons (with no names); a textbox named n.There is also a DIV block shown with id="p1_pout". The radio buttons have no values clauses. All the radios have onclick events: the 1st one has the event: onclick="p1(0)" the 2nd one has the event: onclick="p1(1)" the 3rd one has the event: onclick="p1(2)" the 4th one has the event: onclick="p1(3)" The function p1 appears as: function p1(n) and is passed a value (0,1,2 or 3 which is stored in the variable n) when a user clicks one of the four radio buttons. Thus in p1, n=0 if the user clicks the 1st radio, and n=1 if the user clicks the 2nd radio, etc. A function has been pre-written named even: This function appears like this: function even(x). This function returns a value of true if the value passed to the function (i.e., x) is an even number. It returns the value false is the number passed to it (i.e., x) is an odd number. The function p1:
In an if statement, the "!" means "not". (e.g., using the even function provided: if ( even(row) ) would be true if the row was even, false if row was odd, but if ( !even(row) ) would be false if the row was even, true if row was odd) Assume the rows of the grid begin numbering at 0 and the columns begin numbering at 0. There is NO table -- just gif images arranged in rows and columns in the DIV block using absolute positioning. Show NO HTML. Show only the javascript for p1. | |
Data from: www.usmayors.org/elections | 2. (50 points) The XML data contained in the textarea shown to the left is named ta and is in a form named f2. The DTD for the XML is shown to the left. The javascript code below loads the data from the textarea into the XML DOM (do not write these lines):
mdata=document.f2.ta.value;
The state loop is: for (i=0;i < root.childNodes.length ;i++) The statename is: root.childNodes[i].childNodes[0].childNodes[0].nodeValue The city loop is: for (j=1;j < root.childNodes[i].childNodes.length ;j++) The six column values for city are: root.childNodes[i].childNodes[j].childNodes[k].childNodes[0].nodeValue where the column loop is: for (k=0; k < 6 ;k++) Show NO HTML. Show only the javascript for p2. |
This is the p2_out DIV block
|