title: How to use AJAX to populate state list depending on Country list?
body: <p>I have the code below that will change a state dropdown list when you change the country list.<br>
  How can I make it change the state list ONLY when country ID number 234 and 224 are selected?<br>
  If another country is selected it should be change into this text input box</p>
  
  <pre><code>&lt;input type="text" name="othstate" value="" class="textBox"&gt;
  </code></pre>
  
  <p><strong>The form</strong></p>
  
  <pre><code>&lt;form method="post" name="form1"&gt;
  &lt;select style="background-color: #ffffa0" name="country" onchange="getState(this.value)"&gt;
  &lt;option&gt;Select Country&lt;/option&gt;
  &lt;option value="223"&gt;USA&lt;/option&gt;
  &lt;option value="224"&gt;Canada&lt;/option&gt;
  &lt;option value="225"&gt;England&lt;/option&gt;
  &lt;option value="226"&gt;Ireland&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;select style="background-color: #ffffa0" name="state"&gt;
  &lt;option&gt;Select Country First&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p><strong>The javascript</strong></p>
  
  <pre><code>&lt;script&gt;
  function getState(countryId)
  {
     var strURL="findState.php?country="+countryId;
     var req = getXMLHTTP();
     if (req)
     {
       req.onreadystatechange = function()
       {
        if (req.readyState == 4)
        {
       // only if "OK"
       if (req.status == 200)
           {
          document.getElementById('statediv').innerHTML=req.responseText;
       } else {
         alert("There was a problem while using XMLHTTP:\n" + req.statusText);
       }
         }
        }
     req.open("GET", strURL, true);
     req.send(null);
     }
  }
  &lt;/script&gt;
  </code></pre>