标签:style onchange creat append nbsp script line utf-8 innertext
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<select size="1" id="a1" style="width: 60px;"></select>
<select size="1" id="a2" style="width: 50px;"></select>
<select size="1" id="a3" style="width: 50px;"></select>
<body>
</html>
<script>
a1=document.getElementById(‘a1‘)
a2=document.getElementById(‘a2‘)
a3=document.getElementById("a3")
for(i=1900;i<2018;i++){
o=document.createElement(‘option‘)
o.innerText=i
a1.appendChild(o)
}
for(j=1;j<13;j++){
p=document.createElement(‘option‘)
p.innerText=j
a2.appendChild(p)
}
for(k=1;k<32;k++){
q=document.createElement(‘option‘)
q.innerText=k
a3.appendChild(q)
}
a2.onchange=function(){
a3.options[28].style.display="inline"
a3.options[29].style.display="inline"
a3.options[30].style.display="inline"
n=a1.selectedOptions[0].value
m=a2.selectedOptions[0].value
if(n%4==0&&n%100!=0||n%400==0){
if(m==2){
a3.options[30].style.display="none"
a3.options[29].style.display="none"
}else{
if(m==4||m==6||m==9||m==11){
a3.options[30].style.display="none"
}
}
}else{
if(m==2){
a3.options[28].style.display="none"
a3.options[30].style.display="none"
a3.options[29].style.display="none"
}else{
if(m==4||m==6||m==9||m==11){
a3.options[30].style.display="none"
}
}
}
}
a1.onchange=function(){
a3.options[28].style.display="inline"
a3.options[29].style.display="inline"
a3.options[30].style.display="inline"
n=a1.selectedOptions[0].value
m=a2.selectedOptions[0].value
if(n%4==0&&n%100!=0||n%400==0){
if(m==2){
a3.options[30].style.display="none"
a3.options[29].style.display="none"
}else{
if(m==4||m==6||m==9||m==11){
a3.options[30].style.display="none"
}
}
}else{
if(m==2){
a3.options[28].style.display="none"
a3.options[30].style.display="none"
a3.options[29].style.display="none"
}else{
if(m==4||m==6||m==9||m==11){
a3.options[30].style.display="none"
}
}
}
}
标签:style onchange creat append nbsp script line utf-8 innertext
原文地址:http://www.cnblogs.com/AK-melody/p/7482121.html