title: Call same method on different entering
body: <p>I'm trying to realize a autocomplete input. It works fine, as far as u don't press enter, then the method "get" posts a empty string to my servlet (in Background). How I must modify the code, that the same GET-Request will also be generated when pressing enter. You can test out "the problem" on <a href="http://ajax.scienceandit.net" rel="nofollow">http://ajax.scienceandit.net</a> . </p>
  
  <pre><code>  &lt;form name="autofillform" method="GET" action="autocomplete.php"&gt;
          &lt;table border="0" cellpadding="5"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;&lt;/th&gt;
                      &lt;th&gt;&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;strong&gt;Composer Name:&lt;/strong&gt;&lt;/td&gt;
                      &lt;td&gt;
                          &lt;input type="text" size="40"
                                 id="complete-field"
                                 onkeyup="doCompletion();"&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td id="auto-row" colspan="2"&gt;
                          &lt;table class="popupBox" style="display: none"&gt;&lt;/table&gt;
                      &lt;/td&gt;
                      &lt;td&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
  
      &lt;/form&gt;
  </code></pre>
  
  <p><strong>Javascript:</strong></p>
  
  <pre><code>var req;
  var isIE;
  var completeField;
  var completeTable;
  var autoRow;
  
  function init() {
      completeField = document.getElementById("complete-field");
      completeTable = document.createElement("table");
      completeTable.setAttribute("class", "popupBox");
      completeTable.setAttribute("style", "display: none");
      autoRow = document.getElementById("auto-row");
      autoRow.appendChild(completeTable);
      completeTable.style.top = getElementY(autoRow) + "px";
  }
  
  function doCompletion() {
          var url = "autocomplete.php?action=complete&amp;id=" + escape(completeField.value);
          req = initRequest();
          req.open("GET", url, true);
          req.onreadystatechange = callback;
          req.send(null);
  }
  
  function initRequest() {
      if (window.XMLHttpRequest) {
          if (navigator.userAgent.indexOf('MSIE') != -1) {
              isIE = true;
          }
          return new XMLHttpRequest();
      } else if (window.ActiveXObject) {
          isIE = true;
          return new ActiveXObject("Microsoft.XMLHTTP");
      }
  }
  
  function callback() {
      clearTable();
  
      if (req.readyState == 4) {
          if (req.status == 200) {
              parseMessages(req.responseXML);
          }
      }
  }
  
  function appendComposer(firstName,lastName,composerId) {
  
      var row;
      var cell;
      var linkElement;
  
      if (isIE) {
          completeTable.style.display = 'block';
          row = completeTable.insertRow(completeTable.rows.length);
          cell = row.insertCell(0);
      } else {
          completeTable.style.display = 'table';
          row = document.createElement("tr");
          cell = document.createElement("td");
          row.appendChild(cell);
          completeTable.appendChild(row);
      }
  
      cell.className = "popupCell";
  
      linkElement = document.createElement("a");
      linkElement.className = "popupItem";
      linkElement.setAttribute("href", "autocomplete.php?action=lookup&amp;id=" + composerId);
      linkElement.appendChild(document.createTextNode(firstName + " " + lastName));
      cell.appendChild(linkElement);
  }
  
  function clearTable() {
      if (completeTable.getElementsByTagName("tr").length &gt; 0) {
          completeTable.style.display = 'none';
          for (loop = completeTable.childNodes.length -1; loop &gt;= 0 ; loop--) {
              completeTable.removeChild(completeTable.childNodes[loop]);
          }
      }
  }
  
  function getElementY(element){
  
      var targetTop = 0;
  
      if (element.offsetParent) {
          while (element.offsetParent) {
              targetTop += element.offsetTop;
              element = element.offsetParent;
          }
      } else if (element.y) {
          targetTop += element.y;
      }
      return targetTop;
  }
  
  function parseMessages(responseXML) {
  
      // no matches returned
      if (responseXML == null) {
          return false;
      } else {
  
          var composers = responseXML.getElementsByTagName("composers")[0];
  
          if (composers.childNodes.length &gt; 0) {
              completeTable.setAttribute("bordercolor", "black");
              completeTable.setAttribute("border", "1");
  
              for (loop = 0; loop &lt; composers.childNodes.length; loop++) {
                  var composer = composers.childNodes[loop];
                  var firstName = composer.getElementsByTagName("firstName")[0];
                  var lastName = composer.getElementsByTagName("lastName")[0];
                  var composerId = composer.getElementsByTagName("id")[0];
                  appendComposer(firstName.childNodes[0].nodeValue,
                      lastName.childNodes[0].nodeValue,
                      composerId.childNodes[0].nodeValue);
              }
          }
      }
  }
  </code></pre>