Chris: Netscape und .length BUG

Beitrag lesen

Hallo,

ein blöder Fehler in Netscape 4 hat mich doch glatt einen Tag Arbeit gekostet!

Probiert mal den Code unten aus. Warum ist denn die 'Länge' des Textfeldes zuerst 'undefined' und dann plötzlich '2'?

<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function formSubmit() {

alert('Text: '+document.formular[1].length);
  alert('Option: '+document.formular[0].length);
  alert('Text: '+document.formular[1].length);

return false;
}

</script>
</head>

<body>
<form name="formular" method="get" action="" onSubmit="return formSubmit();">
  <select name="select">
      <option>1</option>
      <option>2</option>
    </select>
    <input name="Text2" type="text">
  <input type="submit" value="Test">
  </form>
</body>
</html>

Als alternative, ob das Element wirklich eine 'Länge' besitzt, verwende ich folgendes Workaround:

document.formular[1][0]

Wenn jemand mehr zu diesem Problem weiß, bitte posten.

Ciao
Chris