标签:for comm size ble letter script mon none number
我还不太会 所以借鉴一下别人的代码, 防止忘记
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
</style>
</head>
<body>
年份:
<input type="text" id="year" style="width: 100px;" />
<!--<select style="width: 100px;" size="1" id="year">
<option>— —</option>
<option>1995</option>
<option>1996</option>
<option>1997</option>
<option>1998</option>
</select>-->
月份:
<select style="width: 100px;" size="1" id="month">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
日期:
<select style="width: 100px;" size="1" id="day">
</select>
</body>
</html>
<script>
year =document.getElementById("year");
mon =document.getElementById("month");
day =document.getElementById("day");
year.onblur=function(){
years==year.value;
}
dayss=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
mon.onblur =function(){
if(mon.value=2&&(years%4==0||years%100!=0||years%400==0;)){
for(x=0;x<29;x++){
days=document.createElement("option");
day.innerHTML=dayss[x];
day.appendChild(days);
}
}else if(mon.value=2&&(years%4!=0;years%100==0;years%400!=0;)){
for(x=0,x<28;x++){
days=document.createElement("option");
day.innerHTML=dayss[x];
day.appendChild(days);
}
}else if(mon.value=1||mon.value=3||mon.value=5||mon.value=7||mon.value=8||mon.value=10||mon.value=12){
for(x=0.x<31;x++){
days=document.createElement("option");
day.innerHTML=dayss[x];
day.appendChild(days);
}
}else(mon.value=4||mon.value=6||mon.value=9||mon.value=11){
for(x=0;x<30;x++){
days=document.createElement("option");
day.innerHTML=dayss[x];
day.appendChild(days);
}
}
}
</script>
出处:段同学
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style> | |
</style> | |
</head> | |
<body> | |
年份: | |
<input type="text" id="year" style="width: 100px;" /> | |
<!--<select style="width: 100px;" size="1" id="year"> | |
<option>— —</option> | |
<option>1995</option> | |
<option>1996</option> | |
<option>1997</option> | |
<option>1998</option> | |
</select>--> | |
月份: | |
<select style="width: 100px;" size="1" id="month"> | |
<option>1</option> | |
<option>2</option> | |
<option>3</option> | |
<option>4</option> | |
<option>5</option> | |
<option>6</option> | |
<option>7</option> | |
<option>8</option> | |
<option>9</option> | |
<option>10</option> | |
<option>11</option> | |
<option>12</option> | |
</select> | |
日期: | |
<select style="width: 100px;" size="1" id="day"> | |
</select> | |
</body> | |
</html> | |
<script> | |
year =document.getElementById("year"); | |
mon =document.getElementById("month"); | |
day =document.getElementById("day"); | |
year.onblur=function(){ | |
years==year.value; | |
} | |
dayss=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]; | |
mon.onblur =function(){ | |
if(mon.value=2&&(years%4==0||years%100!=0||years%400==0;)){ | |
for(x=0;x<29;x++){ | |
days=document.createElement("option"); | |
day.innerHTML=dayss[x]; | |
day.appendChild(days); | |
} | |
}else if(mon.value=2&&(years%4!=0;years%100==0;years%400!=0;)){ | |
for(x=0,x<28;x++){ | |
days=document.createElement("option"); | |
day.innerHTML=dayss[x]; | |
day.appendChild(days); | |
} | |
}else if(mon.value=1||mon.value=3||mon.value=5||mon.value=7||mon.value=8||mon.value=10||mon.value=12){ | |
for(x=0.x<31;x++){ | |
days=document.createElement("option"); | |
day.innerHTML=dayss[x]; | |
day.appendChild(days); | |
} | |
}else(mon.value=4||mon.value=6||mon.value=9||mon.value=11){ | |
for(x=0;x<30;x++){ | |
days=document.createElement("option"); | |
day.innerHTML=dayss[x]; | |
day.appendChild(days); | |
} | |
} | |
} | |
</script> |
标签:for comm size ble letter script mon none number
原文地址:http://www.cnblogs.com/zJuevers/p/7608794.html