Dynamic Drop Down Menus

>>what a pain in the neck

Page 1 of 1

3 Replies - 2225 Views - Last Post: 05 July 2002 - 12:53 AM

#1 fyrestorm   User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Dynamic Drop Down Menus

Posted 20 June 2002 - 10:49 AM

ok, i'm gonna try and make the most sense that i can but i don't know how well i'll succeed

i want two drop down boxes, in the first one is any options, but in the second i want to put options in there based off of whatever was selected in the first one

so the thing i'm having a hard time with is whenever they choose an option from that first drop down, how do i make the second drop down menu?



i hope that made sense...

Is This A Good Question/Topic? 0
  • +

Replies To: Dynamic Drop Down Menus

#2 skyhawk133   User is offline

  • Head DIC Head
  • member icon

Reputation: 1967
  • View blog
  • Posts: 20,425
  • Joined: 17-March 01

Re: Dynamic Drop Down Menus

Posted 20 June 2002 - 11:41 AM

This is some code from a site I use every day:

<script LANGUAGE="Javascript1.1">
<!--
//this function calls up the sub-category data in the sub-category select box
function show_sub_categories()
{
var doc = document.ticket.sub_category;
if ((doc == null) || (doc.options == null))
return;
//window.alert("show_sub_categories in action");
   var which_category = document.ticket.category.selectedIndex;
   //window.alert(which_category);
   var sub_category = doc.selectedIndex;
   var value;

   if (doc.options[sub_category] == null)
       value = 0;
   else
       value = doc.options[sub_category].value;

   //put the new options into the select box
   var the_selected_category = categories_list[which_category];
   var theSelectedCategoryName;
   var selected_set = 0;

   if (the_selected_category == -97)
      theSelectedCategoryName = "category_97";
   else
      theSelectedCategoryName = "category" + the_selected_category;

   if(Categories[theSelectedCategoryName]==null)
          theSelectedCategoryName = "category_97";

   SubCategoryOptions = new Array();
   for(count = 0; count < Categories[theSelectedCategoryName].length; count++) {
      //use x as index to keep "pick one" option first
   var x = count;
      SubCategoryOptions[x] = new Option();
      SubCategoryOptions[x].text = Categories[theSelectedCategoryName].captions[count];
      SubCategoryOptions[x].value = Categories[theSelectedCategoryName][count];
      if (value == SubCategoryOptions[x].value) {
          selected_set = count;
      }
      doc.options[x] = SubCategoryOptions[x];
   x++;
   }
   doc.length = Categories[theSelectedCategoryName].length;
   doc.selectedIndex = selected_set;
}
//-->

Categories = new Array();

categories_list = new Array( "0"
,"11","10","6","5","8","3","2","9","1","7","12","4", "-97");



Categories.category1 = new Array("!!--------------------Please Select Category--------------------!!"
,"1","2","3","30");

Categories.category1.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"Control Panel","Site Statistics","Other","I can not access my site");

Categories.category2 = new Array("!!--------------------Please Select Category--------------------!!"
,"4","5","6");

Categories.category2.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"Can not connect: Suddenly I can not connect any more","Can not connect: I have never connected successfully","Other");

Categories.category3 = new Array("!!--------------------Please Select Category--------------------!!"
,"7","8","9","10","11","12","13","14","31");

Categories.category3.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"How do I access my email?","Trouble configuring mail software","Trouble getting mail","WebMail problem","Aliases","Forwarding","Majordomo","Other","BigMailBox.com Setup");

Categories.category4 = new Array("!!--------------------Please Select Category--------------------!!"
,"15","16","17","18","19","20","21");

Categories.category4.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"FTP","FrontPage","Control Panel","Other Software","Changes Do Not Occur","Images Do Not Appear","My home page is just a listing of files");

Categories.category5 = new Array("!!--------------------Please Select Category--------------------!!"
,"22","23");

Categories.category5.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"Why has my domain not been registered?","Help with transferring domain");

Categories.category6 = new Array("!!--------------------Please Select Category--------------------!!"
,"24","25","26","27","28","29");

Categories.category6.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"General question","Pre-installed Scripts","Perl","PHP","Internal Server Error","Other");

Categories.category7 = new Array("!!--------------------Please Select Category--------------------!!"
,"32","33","34","35");

Categories.category7.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"I have lost my password","How do I change my password?","Please reset my password","Other");

Categories.category8 = new Array("!!--------------------Please Select Category--------------------!!"
,"36","37","38","39");

Categories.category8.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"Shopping Cart","Secure Server","GPG","Other");

Categories.category9 = new Array("!!--------------------Please Select Category--------------------!!"
,"40","41");

Categories.category9.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"I can not connect to my DB","Other");

Categories.category10 = new Array("!!--------------------Please Select Category--------------------!!"
,"42","43");

Categories.category10.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"Enquiry","Add feature");

Categories.category11 = new Array("!!--------------------Please Select Category--------------------!!"
,"44");

Categories.category11.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"Enquiry");

Categories.category12 = new Array("!!--------------------Please Select Category--------------------!!"
,"45");

Categories.category12.captions = new Array("!!--------------------Please Select Sub Category--------------------!!"
,"Enquiry");
Categories.category0 = new Array("0");
Categories.category0.captions = new Array("!!--------------------Please Select Sub Category--------------------!!");
Categories.category_97 = new Array("0");
Categories.category_97.captions = new Array(" ");
//-->
</SCRIPT>


<SELECT NAME="sub_category">
        <OPTION SELECTED value="0">
<OPTION VALUE=30>I can not access my site
<OPTION VALUE=1>Control Panel
<OPTION VALUE=2>Site Statistics
<OPTION VALUE=3>Other
<OPTION VALUE=5>Can not connect: I have never connected successfully
<OPTION VALUE=4>Can not connect: Suddenly I can not connect any more
<OPTION VALUE=6>Other
<OPTION VALUE=7>How do I access my email?
<OPTION VALUE=8>Trouble configuring mail software
<OPTION VALUE=9>Trouble getting mail
<OPTION VALUE=10>WebMail problem
<OPTION VALUE=11>Aliases
<OPTION VALUE=12>Forwarding
<OPTION VALUE=13>Majordomo
<OPTION VALUE=14>Other
<OPTION VALUE=15>FTP
<OPTION VALUE=16>FrontPage
<OPTION VALUE=17>Control Panel
<OPTION VALUE=18>Other Software
<OPTION VALUE=19>Changes Do Not Occur
<OPTION VALUE=20>Images Do Not Appear
<OPTION VALUE=21>My home page is just a listing of files
<OPTION VALUE=22>Why has my domain not been registered?
<OPTION VALUE=23>Help with transferring domain
<OPTION VALUE=24>General question
<OPTION VALUE=25>Pre-installed Scripts
<OPTION VALUE=26>Perl
<OPTION VALUE=27>PHP
<OPTION VALUE=28>Internal Server Error
<OPTION VALUE=29>Other
<OPTION VALUE=31>BigMailBox.com Setup
<OPTION VALUE=32>I have lost my password
<OPTION VALUE=33>How do I change my password?
<OPTION VALUE=34>Please reset my password
<OPTION VALUE=35>Other
<OPTION VALUE=36>Shopping Cart
<OPTION VALUE=37>Secure Server
<OPTION VALUE=38>GPG
<OPTION VALUE=39>Other
<OPTION VALUE=40>I can not connect to my DB
<OPTION VALUE=41>Other
<OPTION VALUE=42>Enquiry
<OPTION VALUE=43>Add feature
<OPTION VALUE=44>Enquiry
<OPTION VALUE=45>Enquiry
<OPTION VALUE=46>Invoice
<OPTION VALUE=47>Receipt
<OPTION VALUE=48>Suspension Notice
<OPTION VALUE=49>SSL
<OPTION VALUE=50>Telnet
<OPTION VALUE=51>Passwords
<OPTION VALUE=52>Account suspension
<OPTION VALUE=53>Account deletion
<OPTION VALUE=54>Disk quota
<OPTION VALUE=55>MySQL
<OPTION VALUE=56>Email
<OPTION VALUE=57>Links
<OPTION VALUE=58>Domain Name Delegation
<OPTION VALUE=59>Site Statistics
                </SELECT>

Was This Post Helpful? 0
  • +
  • -

#3 fyrestorm   User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Re: Dynamic Drop Down Menus

Posted 20 June 2002 - 11:54 AM

surely there's got to be an easier way to do that.... :dead:
Was This Post Helpful? 0
  • +
  • -

#4 mirza   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 04-July 02

Re: Dynamic Drop Down Menus

Posted 05 July 2002 - 12:53 AM

Hehee one somewhat simpler idea would be to have all the boxes there, but you just hide the non-relevant boxes... Or something :D

Here

<script language="vbscript" type="text/vbscript">
Function fuckie(momma)

If this.value = "yomomma" Then
   document.all.box1.style.visibility = "visible"
   document.all.box1.style.visibility = "hidden"
   document.all.box1.style.visibility = "hidden"
ElseIf this.value = "whoisyerdaddy" Then
   document.all.box1.style.visibility = "hidden"
   document.all.box1.style.visibility = "visible"
   document.all.box1.style.visibility = "hidden"
ElseIf this.value = "andwhatdoeshedo" Then
   document.all.box1.style.visibility = "hidden"
   document.all.box1.style.visibility = "hidden"
   document.all.box1.style.visibility = "visible"
Else
   MsgBox("dunno man!")
End If
End Function
</script>

<!-- ok now this is your first box -->
<select name="somerandommomma" onchange="fuckie(this)">
   <option value="yomomma">yomomma</option>
   <option value="whoisyerdaddy">whoisyerdaddy</option>
   <option value="andwhatdoeshedo">andwhatdoeshedo</option>
</select>

<!-- and here are the rest -->

<select name="box1">
   <option value="yomomma">yomomma</option>
</select>

<select name="box2" style="visibility:hidden;">
   <option value="yomomma">yomomma</option>
</select>
<select name="box3" style="visibility:hidden;">
   <option value="yomomma">yomomma</option>
</select>


ok! now actually i don't think that shit i wrote there will even work! but it should so give it a try... i would almost recommend rewriting the vbscript to javascript! but it was like some years ago since i last did anything in javascript so i figured i'd write this in vbscript... my javascript skillz are no more or something

btw, dunno if that msgbox function is written correctly... dunno if anything is...
but that's the basics... simple i'd say :D

edit: ok now all of my tabs got removed... but there are some nice colors to look at :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1