JavaScript добавляет элементы данных в раскрывающий список. Html
Кода -копия выглядит следующим образом:
<! Doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<TILE> Динамически добавить элементы данных в раскрывающий список </title>
<script type = "text/javascript">
Функциональный гель (id) {return document.getElementById (id); }
window.onload = function () {
var cbbyear = gel ("mysel");
для (var i = 1990; i <2014; i ++) {
// Метод 1
/*var opt = document.createElement ("опция");
opt.innerhtml = i;
cbbyear.appendchild (opt);*/
// Метод 2
var opt = новая опция (i, i);
cbbyear.options.add (opt);
}
};
</script>
</head>
<тело>
<select id = "mysel">
</select>
</body>
</html>