JS erhalten die Anzahl der Elemente des Dropdown-Listenfelds
Die Codekopie lautet wie folgt:
<! DocType html>
<html>
<kopf>
<Script>
Funktion getLength ()
{
alert (document.getElementById ("mySelect"). Länge); // Anzahl der Elemente
}
</script>
</head>
<body>
<form>
<select id = "mySelect">
<OPTION> Apple </Option>
<OPTION> PEAR </option>
<OPTION> BANANA </option>
<OPTION> orange </option>
</select>
<input type = "button" "onclick =" getLength () "value =" Wie viele Optionen in der Liste? ">
</form>
</body>
</html>