js创建下拉列表内容

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js创建下拉列表的内容</title>
</head>
<body>
<form name="myform" action="" method="post">
<select name="xuan" onchange="changeForm()" >
   <option value="98.3-99.6">100</option>
   <option value="49.5-49.7">50</option>
   <option value="19.6-19.8">20</option>
   <option value="9.7-9.9">10</option>
</select><span id="pay" style="color:#900;">98.3-99.6</span>
<select name="year" ></select>年
<select name="month" ></select>月
<select name="day" ></select>日


</form>
<script type="text/javascript">
function changeForm(){
	price=document.myform.xuan.value;
	document.getElementById("pay").innerHTML=price;
}
for(i=1945;i<=2012;i++){
    document.myform.year.options.add(new Option(i));
}
for(i=1;i<=12;i++){
    document.myform.month.options.add(new Option(i));
}
for(i=1;i<=31;i++){
    document.myform.day.options.add(new Option(i));
}

</script>
</body>
</html>

 

posted @ 2012-04-20 17:36  lines  阅读(1414)  评论(0)    收藏  举报