User Tools

Site Tools


eg-259:homework:11

JavaScript and HTML Documents: part 2

Adapted from: Robert W. Sebasta, Programming the World-Wide Web, 3rd Edition, Addison Wesley, 2006. Supporting: Contact Hour 13.

  1. Rewrite the document for the exercises of the previous lecture to use the DOM 2 event model.
  2. Develop, test, and validate an HTML document that has check boxes for apple (59p each), orange (49p each), and banana (39p each), along with a submit button. Each of the check boxes should have its own onclick event handler. These handlers must add the cost of their fruit to the total cost. An event handler for the Submit button must produce an alert window with the message "Your total cost is xxx p," where xxx is the total cost of the chosen fruit plus 17.5 percent VAT. This handler must return false (to avoid actual submission of the form data).
  3. Develop, test, and validate an HTML document that is similar to that of Exercise 2. In this case, use text boxes rather than check boxes. These text boxes take a number, which is the purchased number of the particular fruit. The rest of the document should behave exactly like that of Exercise 2.
  4. Add reality checks to the text boxes of the document in Exercise 3. The checks on the check box inputs should ensure that the input values are numbers in the range 0-99.
  5. Revise the document of Exercise 3 to use the DOM 2 event model.

More Homework Exercises

eg-259/homework/11.txt · Last modified: 2012/02/17 15:59 by eechris