Hi All,

the following code is used to get an update from a database. My question is how can I use this more than once on a page to call two different queries (from different php files)?

<html>
<head>
<script type="text/javascript">
function showHint(str)
{
  if (window.XMLHttpRequest)
    xmlhttp = new XMLHttpRequest();
  else
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

  xmlhttp.onreadystatechange = function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
      document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
  };
  xmlhttp.open("GET", "console4.php" + str, true);
  xmlhttp.send(null);
}
</script>
</head>
<body>
<script type="text/javascript">showHint(this.value)</script>

<p><span id="txtHint"></span></p> 
</body>
</html>

      <script type="text/javascript">
      function keepCalling() {
      showHint("");
      window.setTimeout("keepCalling()", 2000) ;// call the showHint every (2)000 second
      }
      keepCalling();
      </script>

I would extend the function showHint to accept two more parameters: the first being the php file to call, and the second the elementId to update. That way you can keep using the same function.