// Ordered Selection using Multiple Dropdowns
// copyright 21st February 2006, by Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration

function listSel(fld,id) {
var opt = fld.selectedIndex;
var myform = document.getElementById(id);
var optarray = myform.getElementsByTagName('select');
var val = fld.options[opt].value;
for (var i=optarray.length-1;i > -1; i--) {
   for (var j = optarray[i].length-1; j > -1; j--) {
      if (optarray[i] == fld) {
         if (fld.options[j].value != val) {
            fld.removeChild(optarray[i].options[j]);
            }}
      else if (optarray[i].options[j].value == val) {
         optarray[i].removeChild(optarray[i].options[j]);
         }
      }
   }
for (var k=optarray.length-1;k > -1; k--) {
   if (optarray[k].length != 1) break;
   }
if (k == -1) {
   var al = 'Your selections in order are:\n   ';
   for (var i=0;i < optarray.length; i++) {
      al += optarray[i].options[0].text + '\n   ';
      }
   alert(al);
   }
}      