|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a script that is a double drop down menu. One side is year - other is months. My problem is. I have to reset the year every time I want to change months. I would like to be able to select say year 2009 and then choose jan - feb etc or the same for 2010 and 2011 etc. Can anyone tell me how to do this.
Here is the script I have <script language="javascript"> <!--// //new Option("text","value") //this code changes menus function nullOptionsDMA(aMenu){ var tot=aMenu.options.length for (i=0;i<tot;i++) { aMenu.options[i]=null } aMenu.options.length=0; } function MySubjectDMA0(aMenu){ nullOptionsDMA(aMenu) with (aMenu){ //Rewrites the text and values options[0]=new Option("Select a page","none"); options[1]=new Option("January","9jan.html"); options[2]=new Option("Feburay","9feb.html"); options[3]=new Option("March","9mar.html"); options[4]=new Option("April","9apr.html"); options[5]=new Option("May","9may.html"); options[6]=new Option("June","9jun.html"); options[7]=new Option("July","9jul.html"); options[8]=new Option("August","9aug.html"); options[9]=new Option("September","9sep.html"); options[10]=new Option("October","9oct.html"); options[11]=new Option("November","9nov.html"); options[12]=new Option("December","9dec.html"); options[0].selected=true } } function MySubjectDMA1(aMenu){ nullOptionsDMA(aMenu) with (aMenu){ //Rewrites the text and values options[0]=new Option("Select a page","none"); options[1]=new Option("January","0jan.html"); options[2]=new Option("Feburay","0feb.html"); options[3]=new Option("March","0mar.html"); options[4]=new Option("April","0apr.html"); options[5]=new Option("May","0may.html"); options[6]=new Option("June","0jun.html"); options[7]=new Option("July","0jul.html"); options[8]=new Option("August","0aug.html"); options[9]=new Option("September","0sep.html"); options[10]=new Option("October","0oct.html"); options[11]=new Option("November","0nov.html"); options[12]=new Option("December","0dec.html"); options[0].selected=true } } function MySubjectDMA2(aMenu){ nullOptionsDMA(aMenu) with (aMenu){ //Rewrites the text and values options[0]=new Option("Select a page","none"); options[1]=new Option("January","11/jan.html"); options[2]=new Option("Feburay","11/feb.html"); options[3]=new Option("March","11/mar.html"); options[4]=new Option("April","11/apr.html"); options[5]=new Option("May","11/may.html"); options[6]=new Option("June","11/jun.html"); options[7]=new Option("July","11/jul.html"); options[8]=new Option("August","11/aug.html"); options[9]=new Option("September","11/sep.html"); options[10]=new Option("October","11/oct.html"); options[11]=new Option("November","11/nov.html"); options[12]=new Option("December","11/dec.html"); options[0].selected=true } } function MySubjectDMA3(aMenu){ nullOptionsDMA(aMenu) with (aMenu){ //Rewrites the text and values options[0]=new Option("Select a page","none"); options[1]=new Option("9January","12/jan.html"); options[2]=new Option("Feburay","12/feb.html"); options[3]=new Option("March","12/mar.html"); options[4]=new Option("April","12/apr.html"); options[5]=new Option("May","12/may.html"); options[6]=new Option("June","12/jun.html"); options[7]=new Option("July","12/jul.html"); options[8]=new Option("August","12/aug.html"); options[9]=new Option("September","12/sep.html"); options[10]=new Option("October","12/oct.html"); options[11]=new Option("November","12/nov.html"); options[12]=new Option("December","12/dec.html"); options[0].selected=true } } /* ####################### goDM() ####################### */ function goDMA(aMenu){ if (aMenu.options.value!="none") { location=aMenu.options[aMenu.selectedIndex].value } } /* ####################### setUp ####################### */ function setUpDMA(){ with (document.formDoubleMenuDMA) { if (menuSubjectsDMA.selectedIndex==0){ menuSubjectsDMA.options[0].selected=true menuFilesDMA.options[0].selected=true } if (menuSubjectsDMA.selectedIndex==1) MySubjectDMA0(menuFilesDMA) if (menuSubjectsDMA.selectedIndex==2) MySubjectDMA1(menuFilesDMA) if (menuSubjectsDMA.selectedIndex==3) MySubjectDMA2(menuFilesDMA) if (menuSubjectsDMA.selectedIndex==4) MySubjectDMA3(menuFilesDMA) } } /* ####################### changeFiles ####################### */ function changeFilesDMA(){ aMenu=document.formDoubleMenuDMA.menuSubjectsDMA aMenu2=document.formDoubleMenuDMA.menuFilesDMA with (aMenu){ switch (selectedIndex) { case 0: aMenu2.options.length=0; aMenu2.options[0]= new Option("Pages appear here","none") aMenu2.options[0].selected=true; history.go(0) break case 1: MySubjectDMA0(aMenu2) aMenu2.options[0].text="Month" break case 2: MySubjectDMA1(aMenu2) aMenu2.options[0].text="Month" break case 3: MySubjectDMA2(aMenu2) aMenu2.options[0].text="Month" break case 4: MySubjectDMA3(aMenu2) aMenu2.options[0].text="Month" break } } } //--> </script> <body> <form name="formDoubleMenuDMA" > <p> <!-- This menu holds the subjects--> <select name="menuSubjectsDMA" onChange="changeFilesDMA()"> <option value="none" >Year <option value="">2009 <option value="">2010 <option value="">2011 <option value="">2012 </select> <!-- this menu holds the files to go--> <select name="menuFilesDMA" onChange="goDMA(this)" style="width:80"> <option value="none"> Month </select> <p> </form> |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Dual Drop Down |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|