Axel Richter: Einträge aus Auswahllisten mit "=null" löschen

Beitrag lesen

Hallo,

switch(x)
          {
          case "1":
          document.spiel.wahl.options[3] = null;

Nun gibt es document.spiel.wahl.options[3] nicht mehr. Das ehemalige document.spiel.wahl.options[4] wird zum document.spiel.wahl.options[3], das ehemalige document.spiel.wahl.options[5] wird zum document.spiel.wahl.options[4] usw.

document.spiel.wahl.options[4] = null;

Hier wird document.spiel.wahl.options[4], das ehemalige document.spiel.wahl.options[5] gelöscht. Das ehemalige document.spiel.wahl.options[6], zwischendurch zu document.spiel.wahl.options[5] geworden, wird nun document.spiel.wahl.options[4].

document.spiel.wahl.options[5] = null;

document.spiel.wahl.options[5] gibt es schon nicht mehr.

document.spiel.wahl.options[6] = null;

document.spiel.wahl.options[6] gibt es ebenso nicht mehr.

break;

aber irgendwas scheint da falsch zu sein. Wenn x den Wert "1" hat, dann werden .options [3] und .options [5] gelöscht, [4] und [6] hingegen nicht. woran kann das liegen?

Woran das liegt, ist oben logisch erklärt ;-))

viele Grüße

Axel