JS Instance 8th-time selection

Source: Internet
Author: User

<body>

<select id= "nian" onclick= "biantian ()" ></select> Year
<select id= "yue" onclick= "biantian ()" ></select> Month
<select id= "tian" ></select> Day

<script type= "text/javascript" >
Fillnian ();
Fillyue ();
Filltian ();
function Fillnian ()
{
var b = new Date (); Get current time
var Nian = parseint (b.getfullyear ());

var str = "";

For (var I=nian-5;i<nian+6;i++)
{
str = str+ "<option value= '" +i+ ">" +i+ "</option>";
}

document.getElementById ("nian"). InnerHTML = str;

}

function Fillyue ()
{
var str = "";
For (var I=1;i<13;i++)
{
str = str+ "<option value= '" +i+ ">" +i+ "</option>";
}
document.getElementById ("yue"). InnerHTML = str;
}

function Filltian ()
{
var yue = document.getElementById ("yue"). value;
var Nian = document.getElementById ("nian"). value;
var ts = 31;

If (yue==4 | | yue==6 | | yue==9 | | yue==11)
{
ts=30;
}

If (yue==2)
{
If ((nian%4==0 && nian%100! = 0) | | nian%400==0)
{
TS = 29;
}
Else
{
TS = 28;
}
}

var str = "";
For (var I=1;i<ts+1;i++)
{
str = str+ "<option value= '" +i+ ">" +i+ "</option>";
}
document.getElementById ("tian"). InnerHTML = str;



}


function Biantian ()
{
Filltian ();
}
</script>
</body>

JS Instance 8th-time selection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.