// JavaScript Document
// Darren George

function getUsernames(processFile, textField)
  {    
  url = processFile + "?" + textField.name + "=" + textField.value;
  
  MakeServerRequest(url);     
  }
    
function DisplayServerResponse(serverResponse)
  {
  //root element of the xml document being parsed
  var xmlDoc = serverResponse.documentElement;

  //set the statusMsg field to the empty string
  document.getElementById("statusMsg").innerHTML = "";  
  
  //set the name field to the empty string
  document.forms[0].name.value = "";

  //remove all options from the <select> list if any are present
  var listUsers = document.getElementById("listUsers");
  listUsers.options.length = 0;

  //put the textual content of <statusMsg></statusMsg> from the XML document into the <span id="statusMsg"></span> HTML element
  var statusMsg = xmlDoc.getElementsByTagName("statusMsg")[0];
  document.getElementById("statusMsg").innerHTML = statusMsg.firstChild.nodeValue;

  //get the list of <username></username> tags from the XML document    
  var usernames = xmlDoc.getElementsByTagName("username");

  for(i = 0; i < usernames.length; i++)
    {
    //take the textual content of the <username></username> element(s) from the XML document and put it between a newly created
    //<option></option> element that is then inserted into the <select id="listUsers"></select> element in the HTML document 
    listUsers.options[i] = new Option(usernames[i].firstChild.nodeValue, usernames[i].firstChild.nodeValue);
    }    
  }   

