blumi: .option IE6

Beitrag lesen

Hallo Leute!
Habe ein eigenartiges Problem .......

Ein Dropdown soll den Inhalt eines anderen Dropdowns steuern. Weil display oder visible nicht bei allen Browser funktioniert filtere ich eine 3. Dropdown aus den Inhalten der befüllten unsichtbaren 2. Dropdown.

Eigentlich funktioniert das alles blendend, nur IE6 hat als Anfangswert immer eine Subkategorie über der eigentlichen:

Das eigenartige: Wechselt man hin und her - stimmts ...
gibt man einen alter aus - stimmts auch

Weiß jemand eine Lösung?

Hier der Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
 <title>test</title>
<script>
function subkat_wechsel(nr) {
 x = 0;
 //subsel löschen
 for (j=0;j<document.f.subsel.length;j++) {
  try {
   document.f.subkat.remove(document.f.subkat.options[j]); // firefox
  } catch (ex) {
   document.f.subkat.remove(j); // ie
  }
 }
 // 0 - Wert einfügen
 subkat(0,'keine Sub-Kategorie',0,x);
 x++;
 //Überprüfen
 for (i=0;i<document.f.kat.length;i++) {
  if (document.f.kat.options[i].selected==true) {
   wert =  document.f.kat.options[i].value;
   for (j=0;j<document.f.subsel.length;j++) {
    subkat_value = document.f.subsel.options[j].value;
    wortlaut = document.f.subsel.options[j].text;
    //Format: 3_7 ---> "kat_id"_"subkat_id"
    akt_werte = subkat_value.split("_");
    sele=0;
    if (document.f.subsel.options[j].selected==true) sele=1;
    if (akt_werte[0]==wert) {
     subkat(akt_werte[1],wortlaut,sele,x,nr);
     x++;
    }
   }
  }
 }
}

function subkat(wert, wortlaut, sele, x, nr) {
 subkat_option = document.createElement('option');
 if (sele==1) subkat_option.selected = true;
 subkat_option.text = wortlaut;
 subkat_option.id = wert;
 subkat_option.value = wert;

//alert(wortlaut+"("+wert+"): "+sele);
 try {
  document.f.subkat.add(subkat_option, (x)); // ie
 } catch (ex) {
  document.f.subkat.add(subkat_option, document.f.subkat.options[x]); // firefox
 }
}
</script>
</head>

<body>
<form name="f" method="post">
<b>Kategorie:</b>
<select name='kat' style='width:180px' onChange='subkat_wechsel()'>
<option value='6'>Erlebnis</option>
<option value='5'>Kreativ</option>
<option value='3'>Kultur</option>
<option value='1' selected>Natur</option>
<option value='4'>Sport</option>
<option value='2'>Wasser</option>
</select>
<br>
<b>Sub-Kategorie:</b>
<select name='subkat' id='subkat'></select>
<select name='subsel' id='subsel' style='width:180px; visibility:hidden'>
<option value='1_3'>Wandern</option>
<option value='1_4'>Blumenwiese</option>
<option value='1_5' selected>Reiten</option>
<option value='5_6'>Zeichnen</option>
<option value='5_7'>Malen</option>
<option value='5_8'>Formen</option>
<option value='6_1'>Bahn</option>
<option value='6_2'>Schiff</option>
</select>
<script>
subkat_wechsel();
</script>
</form>
</body>
</html>