Select a type of pet that you like.

A copy of the JavaScript functions in the head element:

// sample-5-multiple-select.js
// This sample shows processing of a multiple select list


// Reset values onload of the body
function loaded()
  {
  var pet = document.getElementById("pet");
  pet.selectedIndex = 5;  // selects none
  }


// select list onchange handler
function pet_function()
  {
  var pet_list  = document.getElementById("pet");
  var result_area = document.getElementById("result");
  result_area.innerHTML = "Selected pets<br />";  // reset result text

  for(var pet_index=0; pet_index<pet_list.options.length; pet_index++)
    {
    if(pet_list.options[pet_index].selected)
      {
      result_area.innerHTML = result_area.innerHTML+"index: "+pet_index+"   pet: "+pet_list.options[pet_index].value+"<br />"
      }
    }
  }