Use JavaScript to write year, month, and day

Source: Internet
Author: User

<HTML> </P> <p> <pead> </P> <p> <title> </title> <br/> <MCE: script Type = "text/JavaScript"> <! -- <Br/> function Init () <br/> {<br/> var year = $ ("year "); <br/> var month = $ ("month"); <br/> var day = $ ("day "); <br/> // var mvalue = $ ("month "). value; // The value of the month mentioned <br/> //// display the year // <br/> for (VAR I = 1980; I <= 2010; I ++) <br/>{< br/> var op = New Option (I, I); <br/> year. options. add (OP ); <br/>}< br/> /// display month // <br/> for (VAR I = 1; I <= 12; I ++) <br/>{< br/> var op = New Option (I, I); <br/> month. options. add (OP); <br/>}< br/> for (VAR I = 1; I <= 31; I ++) <br/>{< br/> var op = New Option (I, I); <br/> day. options. add (OP); <br/>}< br/> function changeday () <br/>{< br/> var day =$ ("day"); <br/> var mvalue =$ ("month "). value; // The value of the month mentioned <br/> var arr1 = new array ("4", "6", "9", "11 "); <br/> var arr2 = new array ("1", "3", "5", "7", "8", "10", "12 "); <br/> /// check whether the selected value is displayed in the loop array. <br/> //// 30 days <br/> for (VAR I = 0; I <arr1.leng Th; I ++) <br/>{< br/> If (mvalue = arr1 [I]) <br/>{< br/> day. options. length = 0; // empty value <br/> for (VAR j = 1; j <= 30; j ++) <br/>{< br/> var OP1 = New Option (J, J); <br/> day. options. add (OP1 ); <br/>}</P> <p >}< br/> // 31 days // <br/> for (VAR I = 0; I <arr2.length; I ++) <br/>{< br/> If (mvalue = arr2 [I]) <br/>{< br/> day. options. length = 0; // empty value <br/> for (VAR j = 1; j <= 31; j ++) <br/>{< br/> var OP1 = new o Ption (J, J); <br/> day. options. add (OP1 ); <br/>}</P> <p >}< br/> /// // 29 days of the year of the Swiss, 28 days per year <br/> If (mvalue = 2) <br/> {<br/> var yr = $ ("year "). value; <br/> If (yr % 4 = 0 & yr % 100! = 0 | yr % 400 = 0) <br/>{< br/> day. options. length = 0; // empty value <br/> for (VAR j = 1; j <= 29; J ++) <br/>{< br/> var OP1 = New Option (J, J); <br/> day. options. add (OP1); <br/>}< br/>} else <br/>{< br/> day. options. length = 0; // empty value <br/> for (VAR j = 1; j <= 28; j ++) <br/>{< br/> var OP1 = New Option (J, J); <br/> day. options. add (OP1); <br/>}</P> <p> function $ (STR) <br/>{< br/> return document. getelementbyid (STR); <br/>}< br/> // --> </MCE: SCRIPT> <br/> </pead> </P> <p> <body onload = "Init ()"> <br/> select: <select id = "year"> </SELECT> year <select id = "month" onchange = "changeday () "> </SELECT> month <select id =" day "> </SELECT> day <br/> </body> </P> <p> </ptml> <br/>

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.