title: fill multiple textbox from database the ajax way
body: <p>I am new with ajax.
  I have a dropdown that fills from database
   and 4 textbox.
  when user select a title from dropdown the textboxes should fill automatically.</p>
  
  <p>here is my javascript code.</p>
  
  <pre><code>function getXMLHttp()
  {
    var xmlHttp
  
    try
    {
      //Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
    }
    catch(e)
    {
      //Internet Explorer
      try
      {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e)
      {
        try
        {
          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e)
        {
          alert("Your browser does not support AJAX!")
          return false;
        }
      }
    }
    return xmlHttp;
  }
  
  function MakeRequest(username)
  {
    var xmlHttp = getXMLHttp();
  
    xmlHttp.onreadystatechange = function()
                                 {
                                      if(xmlHttp.readyState == 4 &amp;&amp; xmlHttp.status == 200)
                                       {
                                          HandleResponse(xmlHttp.responseText);
                                       }
                                  }
  
    xmlHttp.open("GET","ajax.php?username="+username,true);
    xmlHttp.send(null);
  }
  
  function HandleResponse(response)
  {
    document.getElementById("f").value = response; 
  }
  </code></pre>
  
  <p>and this is my php code</p>
  
  <pre><code>    require_once'/classes/USRclass.php';
  if(isset($_GET['username']))
  {
      $username=$_GET['username'];
      $usr1=new USER;
      $where="username='$username'";
      $a=$usr1-&gt;show($where);
      echo $a['name'];
      echo $a['family'];
      echo $a['email'];
      echo $a['privilege'];
  }
  </code></pre>
  
  <p>and this is my form</p>
  
  <pre><code>&lt;form method="get"&gt;
      username:&lt;select name="username" onChange="MakeRequest(this.value)"&gt;
          &lt;option&gt;&lt;/option&gt;
          &lt;?php
          require_once'/classes/USRclass.php';
          $usr1=new User;
          $a=$usr1-&gt;show_all_field('username');
          if(count($a)==1)
          {
          foreach($a as $key)
           echo"&lt;option&gt;$key&lt;/option&gt;";
          }
          else if(count($a&gt;1))
          {
          foreach($a as $key)
              foreach($key as $column=&gt;$val)
                  echo"&lt;option&gt;$val&lt;/option&gt;";
          }
          ?&gt;      
          &lt;/select&gt;&lt;br&gt;
          name: &lt;input id="n" type="text" name="u_name"&gt;&lt;br&gt;
          family:  &lt;input type="text" name="u_family" id="f"&gt;&lt;br&gt;
          email: &lt;input type="text" name="u_email"&gt;&lt;br&gt;
          privilege: &lt;input type="text" name="u_privilege"&gt;&lt;br&gt;
          &lt;input type="button" name="u_edit" value="Edit"&gt;
          &lt;input type="submit" name="u_ok" value="OK"&gt;
          &lt;/form&gt;
  </code></pre>