The implementation of a year, month, quarterly linkage select JavaScript code _ form Effects

Source: Internet
Author: User
<body> <table border=0 height=30px > <tr> <td width=80px> <select onchange= "Displaysubmenu (this.value) "> <option value=" None > Please select report type </option> <option value= "1,4" > Monthly Report </option> <option value= "1,3" > Quarterly report </option> <option value= "1,2" > Half-year report </option> <option value= "1" > Annual report </option> </select> </td> <td> <select id= "submenu_1" name= "year" ></select& Gt </td> <td> <select id= "submenu_2" name= "Semiyear" ></select> <select id= "Submenu_3" Name= "q Uarter "></select> <select id=" Submenu_4 "name=" month "></select> </td> <td> &LT;INP UT id= "OK" type= "button" onclick= ' GetValue (); ' value= ' value ' > </td> </tr> </table> <script> function GetValue () {var objlist = document.getelementsbytagname ("select"); var tmp = new Array (); var tap = Objlist[0].options[objlist[0].Selectedindex].text; Strtmp= ""; var j = 1; for (Var i=1;i<objlist.length;i++) {if (objlist[i].style.display!= "None") {strtmp = = Objlist[i].opt Ions[objlist[i].selectedindex].text + "-"; j + +; } strtmp = Strtmp.substring (0,strtmp.length-1); alert (TAP); alert (strtmp); function Hideall () {for (i=1;i<5;i++) {var select = document.getElementById ("submenu_" +i); while (select.options.length>0) {select.options.remove (0); } Select.style.display = "None"; } function Initselect (index) {var select = document.getElementById ("submenu_" +index); var now = new Date (); var currentyear = Now.getyear (); var month = Now.getmonth (); Switch (index) {case 1:for (i=-5;i<=5;i++) {var value = Currentyear+i; var item = new Option (value,value); Select.options.add (item); } Select.selectedindex = 5; Select.style.display = "block"; Break Case 2:var Semiyears = new Array ("first half", "second half"); for (i=0i<2;i++) {var item = new Option (semiyears[i],i+1); Select.add (item); } Select.selectedindex = Math.floor (MONTH/6); Select.style.display = "block"; Break Case 3:var quarters = new Array ("First quarter", "Two Quarter", "Three Quarter", "four Quarter"); for (i=0;i<4;i++) {var item = new Option (quarters[i],i+1); Select.add (item); } Select.selectedindex = Math.floor (MONTH/3); Select.style.display = "block"; Break Case 4:var months = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); for (i=0;i<12;i++) {var item = new Option (months[i],i+1); Select.add (item); } select.selectedindex = month; Select.style.display = "block"; Break Default:break; }} function Displaysubmenu (command) {hideall (); if (Command!= "none") {var commands = Command.split (","); for (l=0;l<commands.length;l++) {initselect (parseint (commands[l)); }} </script> </body>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.