title: Populate one fieled when other related field is entered
body: <p>I have two fields in my database
  Roll No and Name
  I have designed a html form where there are two input types
  One --> "Roll No"
  and other is "Name"</p>
  
  <p>i want when i enter the roll number in the roll number field and press tab the name field should fill up automatically fetched from the data base.</p>
  
  <p>My codes are here</p>
  
  <p><strong><em>index.php</em></strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="jquery-1.7.1.min.js"&gt;&lt;/script&gt; 
  &lt;script type="text/javascript"&gt;
  var searchTimeout; //Timer to wait a little before fetching the data
  $("#roll").keyup(function() {
      searchKey = this.value;
  
      clearTimeout(searchTimeout);
  
      searchTimeout = setTimeout(function() {
          getUsers(searchKey);    
      }, 400); //If the key isn't pressed 400 ms, we fetch the data
  });
  
  function getUsers (searchKey) {
      $.ajax({
          url: 'getUser.php',
          type: 'POST',
          dataType: 'json',
          data: {value: searchKey},
          success: function(data) {
              if(data.status) {
                  $("#name").val(data.userData.name);
              } else {
                  // Some code to run when nothing is found
              }   
          }
      });         
  }
  &lt;/script&gt;
  &lt;/head&gt;             
  
  &lt;table&gt;
  &lt;tr&gt;
      &lt;td&gt;Roll&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="roll" id="roll" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
      &lt;td&gt;Name&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="name" id="name" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong><em>getUser.php</em></strong></p>
  
  <pre><code>&lt;?php
  include "db.php";
  
  $response = Array();
  
  $response['status'] = false;
  
  $query = mysql_query("SELECT `name` FROM `tab` WHERE `roll` LIKE '%".$_POST['value']."%' LIMIT 1"); //Or you can use = instead of LIKE if you need a more strickt search
  
  if(mysql_num_rows($query)) {
      $userData = mysql_fetch_assoc($query);
  
      $response['userData'] = $userData;
      $response['status'] = true;            
  }
  
  echo json_encode($response);
  ?&gt;
  </code></pre>