previous | index | next

Using the $() Function

Clearing and setting the city and state fields require accessing the element from the DOM tree.

The Prototype's $() function is a handy shorthand for window.document.getElementById():

      function clearCityAndStateFields() {
          $("form:city").value  = "";
          $("form:state").value = "";
      }
      function setCityAndStateFields(city, state) {
          $("form:city").value  = city;
          $("form:state").value = state;
      }

previous | index | next