6. Client-Side Processing


  1. Client-side processing
  2. JavaScript
  3. Client-side scripting
  4. Document Object Model (DOM)
  5. Document methods and properties
  6. Events
  7. Calling a function
  8. Table of squares function
  9. Comments on previous script
  10. Defining a function
  11. Event handlers
  12. Event handlers example
  13. Event listeners
  14. Functions and form fields
  15. Defining the function myTranslate
  16. Navigating the DOM tree
  17. Finding elements by name
  18. Finding elements by name (function body)
  19. Using CSS selectors
  20. Adding elements
  21. Deleting elements
  22. Using jQuery
  23. Using jQuery to add elements
  24. Finding elements by name (jQuery)
  25. DOM and XML
  26. jQuery method to load an XML file
  27. Retrieving RSS item titles
  28. Retrieving JSON data
  29. JSON country data
  30. Code for JSON retrieval (1)
  31. Code for JSON retrieval (2)
  32. Exercises
  33. Links to more information

6.1. Client-side processing

6.2. JavaScript

6.3. Client-side scripting

6.4. Document Object Model (DOM)

6.5. Document methods and properties

6.6. Events

6.7. Calling a function

6.8. Table of squares function

6.9. Comments on previous script

6.10. Defining a function

6.11. Event handlers

6.12. Event handlers example

6.13. Event listeners

6.14. Functions and form fields

6.15. Defining the function myTranslate

6.16. Navigating the DOM tree

6.17. Finding elements by name

6.18. Finding elements by name (function body)

6.19. Using CSS selectors

6.20. Adding elements

6.21. Deleting elements

6.22. Using jQuery

6.23. Using jQuery to add elements

6.24. Finding elements by name (jQuery)

6.25. DOM and XML

6.26. jQuery method to load an XML file

$.get("rss-fragment.xml", 
      function( xml ) {
        ...
      },
      "xml"
    );

6.27. Retrieving RSS item titles

6.28. Retrieving JSON data

6.29. JSON country data

6.30. Code for JSON retrieval (1)

6.31. Code for JSON retrieval (2)

6.32. Exercises

  1. Implement the following functions:
  2. Use the functions from (1) to write a script that enables the user to enter either a Fahrenheit temperature and display the Celsius equivalent or enter a Celsius temperature and display the Fahrenheit equivalent. You can either write two new functions that call your functions from (1) or modify those functions instead. Your HTML document should contain a form with two buttons and two input fields. The one button initiates the conversion from Fahrenheit to Celsius, while the other initiates the conversion from Celsius to Fahrenheit. The input fields hold the two temperatures: one as input, the other as output. For simplicity, call the functions using onClick attributes. (see slide 15 and slide 16.)
  3. Now modify the code in (2) so that it does not use onClick attributes but instead binds events to the buttons. Remember to use window.onload to delay the bindings until after the page has loaded (as in slide 13).
  4. Reproduce the code to output information from the RSS document fragment as on slide 27 and slide 28, but outputting item descriptions rather than titles. For this, you will need to save a copy of the RSS document in your own web space (see the intranet for instructions). Your HTML page will also need to be there and you will need to access it over the web, using titan.dcs.bbk.ac.uk/~..., where ... is your username. Your HTML page will also need to reference the jQuery library, either remotely or by saving a copy in your web space. The version I use is here.

6.33. Links to more information

There are many books devoted to Javascript and/or jQuery. DOM is covered in Chapter 7 of [Moller and Schwartzbach] and Chapter 8 of [Jacobs]. See above for books on jQuery.