Web Technologies I - Exam #3

Write your answers on the answer sheets provided. You may refer to any ``quick reference'' pages handed out in class. You may also use printouts of any HTML, Javascript, or applet code you have created for this course.

  1. (3 pts each) Briefly define each of the following terms in the context of client-side Javascript programming. If the term is an acronym then first expand the acronym and then define the term.
    1. DOM
    2. event handler
    3. focus

  2. (6 pts) Contrast static event registration with dynamic event registration.

  3. (16 pts) Write an entire (valid) xHTML document with embedded Javascript that will display a header, three buttons, and a text box. The buttons should be labeled ``Red'', ``Green'', and ``Blue''. The header should be implemented with an <h1> tag and should display the text ``This is fun!''. The text box should initially contain the number 0. If the user clicks on a button have the background of the header change color to the color specified on the button. Also, each time a button is clicked increment the value stored in the text box.

    If you define more than one event handler then demonstrate both static and dynamic event registration. HINT #1: To create a button that is not a submit button use <input type="button" />. HINT #2: If x is a reference to a form element then x.style.background="#000000" will set it to black.

  4. (12 pts) Suppose you have a website that makes use of ``fancy'' social security numbers (FSSN). A FSSN begins just like a regular SSN but has a checkdigit attached to the end. The check digit is calculated by adding up the individual digits of the SSN and the taking the remainder when divided by 10. The resulting digit is added to the end. So, a SSN of 111-22-3333 would have a check digit of: $(1+1+1+2+2+3+3+3+3) \bmod 10 = 19 \bmod 10 =
9$ and the resulting FSSN would be: 111-22-3333-9.

    Write an HTML form (along with Javascript code) that contains a text box that requests a FSSN. When the form is submitted call a validation function that verfies that:

    If the validation fails the form should not be submitted and an alert box should be displayed listing the reason that validation failed. element already exists on the page). If the validation succeeds then the form submission should proceed. (It doesn't matter what action you assign to the form ...).

  5. (8 pts) List the four methods that are a part every applet and state at what point in applet execution they are called.

  6. (6 pts) Name a briefly describe three layout managers.

  7. (4 pts) Name two events that can an ActionListener can respond to.

  8. (16 pts) Write a complete Java applet that will display three buttons (labeled ``A'', ``B'', and ``C'', respectively) and a label (that is initially empty). The buttons should be arranged vertically with the label to the right of them. If the user clicks on one of the buttons then the applet should update the label to indicate which button was clicked on.

  9. (6 pts) Show the HTML code that is necessary to run the applet you created in problem 8.

  10. (6 pts) Write a complete java applet that uses custom drawing to display the message: ``This is MY applet!''.