title: Javascript how to compare two strings
body: <p>This is the Javascript Function. Please Explain How to compare two string in Javascript. </p>
  
  <pre><code>   &lt;head&gt;
      &lt;script type="text/javascript"&gt;
  /*javascript function*/ 
      function ajax(str)
      {
      if (str.length==0)
        {
        document.getElementById("res").innerHTML="";    
        return;
        }
        if(str=="Select City")
        {
        alert("Please Select a City");
        }
      document.getElementById("res").innerHTML=="";
      var url="code1.php?q="+str+"&amp;r"+Math.random();
      var obj;
      try{
      obj=new ActiveXObject(Microsoft.XMLHTTP);
      }
      catch(e)
      {
          try
          {
          obj=new XMLHttpRequest();
          }
          catch(e)
          {
          alert("Your browser not suport ajax");
          }
      }
      obj.open('Get',url,true);
      obj.send(null);
      obj.onreadystatechange=function()
      {
      if(obj.readyState==4)
      {
      document.getElementById("res").innerHTML=obj.responseText;
      }
      }
      }
      &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
  
      &lt;select onchange="ajax(this.value)" name="sel" id="btn"&gt;&lt;option&gt;Dharmashala&lt;/option&gt;&lt;option&gt;Manali&lt;/option&gt;&lt;option&gt;Shimla&lt;/option&gt;&lt;/select&gt;
      &lt;div id="res"&gt;&lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>But it does not work please suggest me a proper method to do this.</p>