JavaScript는 DROPDOW LIST.HTML에 데이터 항목을 추가합니다
코드 사본은 다음과 같습니다.
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text/html; charset = utf-8"/>
<title> 드롭 다운 목록에 데이터 항목을 동적으로 추가합니다 </title>
<script type = "text/javaScript">
function gel (id) {return document.getElementById (id); }
Window.onload = function () {
var cbbyear = gel ( "mysel");
for (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);
}
};
</스크립트>
</head>
<body>
<id = "mysel"을 선택하십시오
</선택>
</body>
</html>