programming-examples/js/Htmldom/Count and display the items of a dropdown list, in an alert window.js

13 lines
348 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function getOptions()
{
var x=document.getElementById("mySelect");
var txt1 = "No. of items : ";
var i;
l=document.getElementById("mySelect").length;
txt1 = txt1+l;
for (i=0;i<x.length;i++)
{
txt1 = txt1 + "\n" + x.options[i].text;
}
alert(txt1);
}