DISC 3371 FALL 2003
Parks Midterm Answers
1. (50 points) An HTML page is designed to allow a user to create a customized greeting card that can be printed.
 1. Choose a Greeting Card Type:
 2. Enter the text of your message to appear inside the card:
   
 3. Enter the signature:
 4. Click when finished
When the page is loaded there is a form named gform; a select box named gsel, with three options: Anniversary, Birthday, and Get-Well. Additionally, there is a textbox with 40 columns and 5 rows named user_text; a textbox named signature; and a button labelled "GO". The "Birthday" option is initial selected. There are three gif files, one for each type of card. They are named: greet1.gif, greet2.gif, and greet3.gif for the Anniversary, Birthday, and Get-Well options, respectively. Each gif file is 300 pixels wide and 400 pixels tall. There is also a single pixel gif file named gwhite.gif that contains a single white pixel.

The user will: (1) select the type of card they desire; (2) enter the text to appear on the card (in the textarea named user_text); (3) enter their signature (in the textbox named signature); and then (4) press the "GO" button. When the "GO" button is pressed, a sub named card is executed.

Using VBScript write ONLY the sub named card (show NO HTML). This sub:
  1. (a) Checks to be sure that there is text in both the textarea and textbox (i.e., user_text and signature must have more than zero characters) and (b) checks to be sure that user_text is has no more than 200 characters and signature has no more than 30 characters. If any entry violates an editing rule, display a message box that indicates to the user what error has been made and exit the sub (show only one error message for each type of error).
  2. Creates a new page on-the-fly that contains a centered two row and two column table. This table:
    1. has a single pixel border and a total width of 600 pixels
    2. the upper left cell contains the gif file associated with the type of card chosen by the user
    3. the upper right cell contains only a single blank space
    4. the lower left cell contains only the gwhite.gif scaled to be 400 pixels tall
    5. the lower right cell contains: the value of user_text centered and printed in red using a font size of 5; followed by a single blank line; then the value of signature centered and printed in blue using a font size of 6. All text is aligned vertically and horizontally within the cell. This cell is 300 pixels wide.
  3. Following the table, print the following instructions (in black using a font size=3): "Cut out the card along the outside borders. Fold the card: first in the middle (along the horizontal line), then vertically (along the vertical line)."
2. (50 points) An HTML table contains 20 radio buttons. The radio buttons appear in the table as shown below:
10 BIT BINARY TO DECIMAL CONVERTER
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Binary String
Decimal Equivalent
The radio buttons in each cell have the same name (e.g., the first cell in the second row has two radio buttons both named c1, in the second cell the two are named c2, in the third cell the two are named c3, etc.) Each radio button has an onClick option that calls a function named show_decimal when the radio button is clicked. These onClick events pass NO arguments to show_decimal (i.e., they only cause the function to be executed if the radio button is clicked).

When executed, the function show_decimal creates a ten digit binary number based on which 10 of the 20 radio buttons are currently checked. This number relies on the fact that only one radio button in each of the ten cells is checked. If the radio button labelled 1 is checked, then the binary digit in that columnar position is set to 1 (one). If the radio button labelled 0 in that cell is checked the binary digit in that columnar position is set to 0 (zero). show_decimal thus determines the composition of a ten digit binary number by extracting one binary digit from the radio buttons in each of the ten cells of the table.

The function then: (1) displays a ten character string representation of the number and stores it in the textbox named bin_str (labelled "Binary String" in the table); and (2) computes the decimal equivalent of the binary number and stores the value in the textbox named dec_out (labelled "Decimal Equivalent" in the table).

The entire table is enclosed in a form named bform. The second radio button in each cell (representing a 1) is initially checked at the time the page is loaded. Additionally the onLoad event in the <BODY> calls the function show_decimal. Thus at the time the page is loaded show_dec determines that all radio buttons labelled 1 are checked. This results in the formation of the string "1111111111" as shown in the "Binary String" textbox above. Further, the value appearing in the textbox labelled "Decimal Equivalent" above is "1023". Write the javascript function show_decimal. Show NO HTML.