title: Calling Javascript function when combobox have only one value
body: <p>I'm calling a Javascript function on <code>onChange</code> event, but this will work only when, we have more than one value in the combobox. I'm confused, which event should be used for selecting the value from the combobox in both case:</p>
  <ol>
  <li>when we have only one value  (don't know)</li>
  <li>when we have multiple value. (<code>onchange</code> will be the best in this
  case)</li>
  </ol>
  <p>Any help appreciated!</p>
  <p>This my code:</p>
  <pre><code>&lt;select name=&quot;zone&quot; id=&quot;zone&quot; onchange=&quot;showDistrict()&quot; &gt;
  &lt;%
   try {
        ResultSet rs = state.executeQuery(&quot;SELECT ZONE_ID,ZONE FROM ZONE ORDER BY ZONE_ID&quot;);
        while (rs.next()) {
                                        %&gt;
  &lt;option value=&quot;&lt;%=rs.getString(1)%&gt;&quot;&gt;&lt;%=rs.getString(2) + &quot; (&quot; + rs.getString(1) + &quot;)&quot;%&gt;&lt;/option&gt;
    &lt;%
      }
   } catch (Exception ex) {
         %&gt;
    &lt;option value=&quot;ERROR&quot;&gt;ZONE NOT AVAILABLE&lt;/option&gt;
     &lt;%                                                        }
                        %&gt;
         &lt;/select&gt;
  </code></pre>
  <p>This is the function, which will retrieve the value as i'll select the value from the combo-box</p>
  <pre><code>function showDistrict(){                   
      document.getElementById(&quot;msg1&quot;).style.display=&quot;block&quot;;
      $.ajax({
          url: '../service/list_district.jsp',
          data: 'zone_id='+ $('#zone').val(),
          type: 'post',
          success: function(msg){document.getElementById(&quot;show_district&quot;).innerHTML=msg;
              document.getElementById(&quot;msg1&quot;).style.display=&quot;none&quot;;
          }});
        }
  </code></pre>