title: Ajax search for multiple parameters usng a single input box
body: <p>Trying to implement a search similar to <a href="http://www.proptiger.com/" rel="nofollow">here</a>.This searches properties based on <strong>city,locality,property name and builder name</strong>.Now have a smaller version working which searches on only the locality name to which I append the city name.</p>
  
  <pre><code>$(document).ready(function(){
          //alert("Entered");
          $("#searchId").keyup(function() 
          {
          var searchbox = $(this).val();
          var dataString = 'searchword='+ searchbox;
  
          if((searchbox=='') || (searchbox=='e.g') )
          {
              //$('#display').css('display') == 'none';
              $('#display').hide();
          }
          else
          {   
  
              if("#searchId".length&gt;3)
          {
              $.ajax({
              type: "POST",
              url: "search.php",
              data: dataString,
              cache: false,
              success: function(html)
              {
                  $("#display").html(html).show();    
  
                  $(".name").click(function(){
                                      //  alert($(this).text());
                                              $("input#searchId").val($(this).text());
                                              $('#display').hide();
                                  }); 
               }          
              });
  
          }
          }return false;    
  
          });                 
  
          });
  </code></pre>
  
  <p>In search.php I have the query like this,</p>
  
  <pre><code>$sql_res=mysql_query("select * from locality as loc inner join cities as cit on loc.city_id=cit.city_id where locality_name like '%$q%' or city_name like '%$q%' order by locality_id LIMIT 5");
  </code></pre>
  
  <p>But I want it to function similar to the link given.The <strong>drop down should show the name of the criteria selected and its type in front</strong> (Ex:Pune(criteria)           city(type)).How can I write a <strong>sql statement and ajax/jquery</strong> function to achive this??<br/></p>
  
  <p><strong>EDIT:</strong>
  Adding the HTML for the input box</p>
  
  <pre><code> &lt;input type="text" autocomplete="off" class="homeinput ac_input" title="Search" id="searchId" name="SearchValue" value="e.g lodha new cuffe parade, thane mumbai" onFocus="if(this.value=='e.g lodha new cuffe parade, thane mumbai') this.value='';" onBlur="if(this.value=='') this.value='e.g lodha new cuffe parade, thane mumbai';"&gt;
  </code></pre>
  
  <p>Thanks for the time.</p>