title: Javascript works only in firefox
body: <p>Can anyone please why does this javascript work only in firefox?</p>
  
  <pre><code>function filter(obj, what, where)
  {
      var v = obj.value;
      var d = document.getElementById(where).getElementsByTagName('optgroup');
  
      if (v &gt; 0)
      {
          for (var i = 0; l = d.length, i &lt; l; i++)
          {
              d[i].className = 'hide';
              if (d[i].id == what + '_' + v)
                  d[i].className = '';
          }
      }
      else
      {
          for (var i = 0; l = d.length, i &lt; l; i++)
              d[i].className = '';
      }
  }
  </code></pre>
  
  <p>I tested it in opera, IE7 and chrome but it doesn't work! Opera error console doesn't show any javascript errors when the page is loaded!</p>
  
  <p>This javascript creates three level auto populating drop down boxes...</p>
  
  <p>I don't know whether it's necessary or not but I post the HTML code too...</p>
  
  <pre><code>State:
  &lt;select name="state" onchange="filter(this, 'state', 'district');"&gt;
      &lt;option value="0"&gt;&lt;/option&gt;
      &lt;option value="1"&gt;State 1&lt;/option&gt;
      &lt;option value="2"&gt;State 2&lt;/option&gt;
      &lt;option value="3"&gt;State 3&lt;/option&gt;
  &lt;/select&gt;
  
  District:
  &lt;select name="district" id="district" onchange="filter(this, 'district', 'city');"&gt;
      &lt;option value="0"&gt;&lt;/option&gt;
      &lt;optgroup id="state_1" label="State 1"&gt;
          &lt;option value="1"&gt;District 1&lt;/option&gt;
          &lt;option value="2"&gt;District 2&lt;/option&gt;
      &lt;/optgroup&gt;
      &lt;optgroup id="state_2" label="State 2"&gt;
          &lt;option value="3"&gt;District 3&lt;/option&gt;
      &lt;/optgroup&gt;
      &lt;optgroup id="state_3" label="State 3"&gt;
          &lt;option value="4"&gt;District 4&lt;/option&gt;
          &lt;option value="5"&gt;District 5&lt;/option&gt;
          &lt;option value="6"&gt;District 6&lt;/option&gt;
      &lt;/optgroup&gt;
  &lt;/select&gt;
  
  City:
  &lt;select name="city" id="city"&gt;
      &lt;option value="0"&gt;&lt;/option&gt;
      &lt;optgroup id="district_1" label="District 1"&gt;
          &lt;option value="1"&gt;City 1&lt;/option&gt;
          &lt;option value="2"&gt;City 2&lt;/option&gt;
          &lt;option value="3"&gt;City 3&lt;/option&gt;
      &lt;/optgroup&gt;
      &lt;optgroup id="district_2" label="District 2"&gt;
          &lt;option value="4"&gt;City 4&lt;/option&gt;
          &lt;option value="5"&gt;City 5&lt;/option&gt;
      &lt;/optgroup&gt;
      &lt;optgroup id="district_3" label="District 3"&gt;
          &lt;option value="6"&gt;City 6&lt;/option&gt;
          &lt;option value="7"&gt;City 7&lt;/option&gt;
      &lt;/optgroup&gt;
  &lt;/select&gt;
  </code></pre>