SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast kcabobert's Avatar
    Join Date
    Aug 2001
    Location
    Topeka, KS
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Drop Down dependant on Drop down

    Okay I searched (and searched...) and I see the drop down radio button forum but I want to make a drop down dependant drop down. like select option 1 - 70 in list 1 then the second box is changed to fit the possibilities, probably 1 - 20 options for most. I think it could do it with an array but I have never used Java (well no "advanced" stuff.) Any advice or thought greatly appreciated.
    Microsoft's Motto: Resistance is futile, you will be assimilated.

    My dog's name is Jade; she is a Miniature pinscher.
    Click here to see some of her pictures

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    San Jose, California
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Enthusiast kcabobert's Avatar
    Join Date
    Aug 2001
    Location
    Topeka, KS
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply. I went out and hunted around for this and found several ways to do several things similar to this. I wound up scrapping them all and trying to write my own, to some poor degree of success. After seeing the link you posted and thinking about what I have and what they have + the diffrences in the two I think I have a good way to create this with PHP so I dont have to type it all (70 catagories with upwards of 120 options in some of the catagories.) I am still open to anysugestions or thoughts.
    Microsoft's Motto: Resistance is futile, you will be assimilated.

    My dog's name is Jade; she is a Miniature pinscher.
    Click here to see some of her pictures

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi kcabobert,

    For another option
    see the Cascading Selects script/tutorial at my site (GrassBlade). It won't save you typing 120 options (unless they are in a database and you can dump them into an array), but it will show you how to use arrays and selection lists

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  5. #5
    SitePoint Enthusiast kcabobert's Avatar
    Join Date
    Aug 2001
    Location
    Topeka, KS
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply, I will check into it. And it happens to be in a DB, the selects are so you can pick catagoreys then specific sections of the catagories
    Microsoft's Motto: Resistance is futile, you will be assimilated.

    My dog's name is Jade; she is a Miniature pinscher.
    Click here to see some of her pictures

  6. #6
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using PHP, you would be able to build the array, and whilst it is in a while loop echo out the select options and the javascript to perform the function.

    But the only problem you might have is then getting it to populate the other select table (not necessarily a problem, but if you have ?1000 options) it might put unnecessary strain on the server, as well as dynamically creating an array for everyone of your options, and its suboptions. Doable, I am sure..
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  7. #7
    SitePoint Enthusiast kcabobert's Avatar
    Join Date
    Aug 2001
    Location
    Topeka, KS
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I think using a while loop I can populate the main selector. Then i can index the subarticles using numbers (or dates) that will have a definite start and end point (ie 1-30 or 20-40) so then I can get the count of the various tables and have an array or something hold the max and min values of each possible "main" select. then using a for loop I can populate the secondary select when the first is changed. If you are able to follow that I would love to have comments or thoughts on it.
    Microsoft's Motto: Resistance is futile, you will be assimilated.

    My dog's name is Jade; she is a Miniature pinscher.
    Click here to see some of her pictures

  8. #8
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Sorry, it's been awhile, but I've been somewhat busy with other things. If the following helps, but you still have problems and little time -- post at the javascriptCity forums -- link in my sig

    <select....onChange=makeSel(this)>
    <option value='min1|max1'>opt1</option>
    <option value='min2|max2'>opt1</option>

    function makeSel(selObj)
    {
    for (i=0;i < selObj.length; i++)
    if (selObj.options[i].selected)
    {
    var ndx = 0;
    tmp = selObj.options[i].value.split("|")
    for (j = tmp[0]; j < tmp[1] ; j++, ndx++)
    document.formname.selectname.options[ndx] = new Option(arrayName[j])
    document.formname.selectname.options[ndx].value = arrayName[j];
    }
    }

    The above presumes
    1) all of the data is in the same array.
    2) you know the position of the min/max for each subselection
    3) the text & value of the new selection list are the same

    If your data is distinctive enough, you might consider using associative (named, not numbered) multi-dimensional arrays

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •