DISC 3371 FALL 2006 Parks Midterm Exam

1. (50 points) A book reseller needs a quick HTML page written in javascript to collect book information from potential internet user who wish to sell their books over the internet. The page shown below shows the relevant data field the book reseller wants on the page. Assume there is a form named sf and a javascript function named form_edit() that is called when the "Click Here for a Quote" button is clicked.


Get a Quote on Selling My Books
BookDrop Internet Book Buyers Inc.
Book Title:
Author 1
Author 2
Author 3
(Enter: First Name or Intial, then Last Name. Omit 3rd, 4th, etc. authors.)
ISBN Number
(Look inside the book opposite the Title page)
Number of Copies
Hard Cover
Soft Cover
When clicked, the function form_edit() performs the following test on the user data
  • Book Title is a 4 row 40 column textarea named bt. Be sure the user enters only upper and lower case letters A through Z (i.e., ASCII 65 is A;...thru...90 is Z; 97 is a;...thru...122 is z). If any other characters are encountered in bt, replace then with a blank space. If the user enters string is longer than 160 bytes, keep only the first 160 bytes. An empty textarea stops the form submission and the message "Book Title cannot be empty" is displayed.

  • The three Author fields (named a1, a2, and a3) require the same A-Z,a-z edit as the Book Title above. An empty textbox for the first author (i.e., a1) stops the form submission and the error message "Author 1 cannot be blank" is displayed. a2 and a3 may be empty.

  • ISBN -- no edits.

  • Number of Copies -- no edits.

  • Hard/Soft Cover -- no edits.

If there are no errors submit the form.

Write only the javascript for form_edit.

2. (50 points)
div block "sout" here
Number of squares
A text box named s accepts a single digit (see below left) and resides in a form named p2form. A button labelled "GO" (below left) calls the vbscript sub named p2. A DIV block with id="sout" is located above the textbox and button (left).

The sub named p2 uses the number in the textbox named s to create a table. The table has a number of rows equal to the value of s.

A 10 pixel by 10 pixel gif file named "dgreen.gif" is placed in the diagonal cells of the table as shown to the left. The size of the gif in the upper right diagonal cell is 10 by 10. In the second row the gif is stretched to twenty by twenty. The third row diagonal gif is thirty by thirty, etc.

Non-diagonal space in the row is spanned by a cell that contains a single blank and has a back ground cell color of "#cccccc".

Thus, the first and last rows have only two cells. All other rows have exactly three cells.

Show only the vbscript for p2.