<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> <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]