JS Implementation date Cascade effect

Source: Internet
Author: User

  This article is mainly on the implementation of the date of JS, the example of the effect of the introduction, the need for friends can come to the reference, I hope to help you.

The code is as follows:     <div>         <select name= "YYYY" onchange= "Yyyymm (this.value)" > &nbs P           <option value= "> Please select year </option>         </select>         <select name= "MM" onchange= "MMDD (this.value)" >           &NBSP ; <option value= "" > select month </option>         </select>         <sel ECT name= "DD" >             <option value= "> select day </option>     &NBSP ;   </select>     </div>       <script language= "JavaScript" >         Function window.onload () {            STRYYYY = Document.form1.YYYY.outerHTM L             STRMM = Document.form1.MM.outerHTML;             STRDD = document. Form1. dd.outerhtml;             Monhead = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];              ///First Nianxia box assignment             var y = new Date (). getFullYear ();             var str = stryyyy.substring (0, stryyyy.length-9);             for (var i = (y-30); i < (y +); i++)//To this year, the first 30 years, after 30 years     &NB Sp       {                str = "<option value= '" + i + "' >" + i + "year" + "</option>rn";                         Document.form1.YYYY.outerHTML = str + "</select>";              //Assign month Drop-down box             var str = Strmm.subst Ring (0, strmm.length-9);             for (var i = 1; i < i++} {                str = "<option value= '" + i + "' >" + i + "month" + "</ Option>rn ";                         Document.form1.MM.outerHTML = str + "</select>";               Document.form1.YYYY.value = y;             Document.form1.MM.value = new Date () getmonth () + 1;             var n = monhead[new Date () getmonth ()];             if (new Date () getmonth () = = 1 && ispinyear (yyyyvalue)) n++;             Writeday (n); Assignment Date dropdown box             Document.form1.DD.value = new Date (). GetDate ();         {        function yyyymm (str)//year change date changes (mainly judged leap excepting)   &NBS P     {          var mmvalue = docUment.form1.mm.options[document.form1.mm.selectedindex].value;             if (Mmvalue = "") {dd.outerhtml = Strdd; Return }             var n = monhead[mmvalue-1];             if (Mmvalue = 2 && ispinyear (str)) n++;             Writeday (n)                   Fun ction MMDD (str)//monthly Change date linkage         {            var yyyyvalue = Docum Ent.form1.yyyy.options[document.form1.yyyy.selectedindex].value;             if (str = "") {dd.outerhtml = Strdd; Return }             var n = monhead[str-1];             if (str = 2 && ispinyear (yyyyvalue)) n++;             Writeday (n)                   function Writeday (n)//Conditional Write date dropdown box         {            var s = Strdd.s Ubstring (0, strdd.length-9);             for (var i = 1; i < (n + 1); i++)             & nbsp   S + + "<option value= '" + i + "' >" + i + "Day" + "</option>rn";             Document.form1.DD.outerHTML = s + "</select>";        }           function ispinyear (year)/determine if leap excepting       &N Bsp {            return (0 = year% 4 && (year%!= 0 | | year% = = 0))        }

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.