49 users online (0 members and 49 guests)  


  Results 1 to 11 of 11

Related

  1. help with two drop down menus    Forum: Javascript Forum
    Replies: 3
  2. Drop Down Menus    Forum: HTML Forum
    Replies: 6
  3. Drop Down Menus    Forum: HTML Forum
    Replies: 1
  4. Drop down menus    Forum: HTML Forum
    Replies: 0
  5. drop down menus    Forum: HTML Forum
    Replies: 2
  1. #1
    bdimi's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Posts
    12

    two drop down menus

    can two drop down menus be linked using html? I want to be able to chose from the first drop down menu (areas of bradford in particular) so that the choises in the second will alter according to the first choice... is it possible?
    thank you

  2. #2
    coreybryant's Avatar
    Texan at Heart

    Status
    Offline
    Join Date
    Jun 2003
    Location
    Castle Rock, CO
    Posts
    107
    You can try something like this, in the <HEAD>:
    <script language="JAVASCRIPT">
    var browser_type=navigator.appName

    var employerArray = new Array("General Information", "Enrollment Services", "Flexible Benefits", "Commuter Choice Program", "COBRA Administration", "Invoice Reconciliation", "Voluntary Benefits", "Payroll Deduction Benefits", "MasterCash ATM Card" , "User Name / Password Problems")
    var employeeArray = new Array("General Information", "Flex Plan", "Commuter Choice Plan","Enrollment Services", "COBRA Administration", "Pending Notifications", "Specific Expenses", "MasterCash ATM Card", "User Name / Password Problems")
    var brokerArray = new Array("General Information", "Flex Plan", "Commuter Choice Plan", "Section 125 Plan" , "Commuter / Transit" , "COBRA Administration", "MasterCash ATM Card", "Voluntary Benefits", "Other")
    var otherArray = new Array("Other")

    function updateList(theForm, catName, subjListLength){
    for (var i=subjListLength + 1 ; i > 0 ; i-- )
    {
    theForm.Subject.options[i] = null
    }
    if( catName == "None"){
    var option0 = new Option("- Please Choose a Category Above -", "None")
    }
    else{
    eval('var option0 = new Option("- Please Choose -", "None")')
    }

    NSL=0
    if (catName != "None") {
    eval("var NewSource = " + catName +"Array")
    NSL = NewSource.length
    for(var L = 0; L < NSL + 1; L++) {
    eval("var option" + [L + 1] + " = new Option(" + '"' + NewSource[L] + '", "' + NewSource[L] + '")')
    }
    }
    for (var i=0; i < NSL + 1; i++) {
    eval("theForm.Subject.options[i]=option" + i)
    if (i==0) {
    theForm.Subject.options[i].selected=true
    }
    }
    if (browser_type=="Netscape")
    { history.go(0) }
    }
    </script>

    And then where you want the dropdown:
    <select name="Category" size="1" onChange="updateList(this.form, this.options[selectedIndex].value, this.form.Subject.length)">
    <option value="None" Selected >- Please Choose - </option>
    <option value="employer" >Employer </option>
    <option value="employee" >Employee </option>
    <option value="broker" >Broker </option>
    <option value="other" >Other </option>
    </select>

    And then the second dropdown:
    <select name="Subject" id="Subject">
    <option value="None" SELECTED>- Please Choose a Category Above - </option>
    </select>

    Just change the coding as you need to - don't forget to change the script in the HEAD as well to match the value of your inputs.

  3. #3
    bdimi's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Posts
    12
    is it possible to do it without using javascript? i an only handle html and sql, plsql...:-|

  4. #4
    coreybryant's Avatar
    Texan at Heart

    Status
    Offline
    Join Date
    Jun 2003
    Location
    Castle Rock, CO
    Posts
    107
    HTML is static. You could not do it.

    Not too sure about SQL, but the code that I gave you is pretty easy if you do understand HTML. you are only changing the options & the vararray

  5. #5
    hijink's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2003
    Posts
    2
    Thanks for the code, but it isn't commented very well.

    Kinda hard to follow. :-/

  6. #6
    coreybryant's Avatar
    Texan at Heart

    Status
    Offline
    Join Date
    Jun 2003
    Location
    Castle Rock, CO
    Posts
    107
    What did you need?

    The vararray is the second drop down. if you look at:
    var employerArray = new Array("General Information", "Enrollment Services", "Flexible Benefits", "Commuter Choice Program", "COBRA Administration", "Invoice Reconciliation", "Voluntary Benefits", "Payroll Deduction Benefits", "MasterCash ATM Card" , "User Name / Password Problems")

    And then at the first drop down:
    <select name="Category" size="1" onChange="updateList(this.form, this.options[selectedIndex].value, this.form.Subject.length)">
    <option value="None" Selected >- Please Choose - </option>
    <option value="employer" >Employer </option>
    <option value="employee" >Employee </option>
    <option value="broker" >Broker </option>
    <option value="other" >Other </option>
    </select>

    If they choose Employer, the value is employer & so the second drop down box would be populated with:
    General Information
    Enrollment Services
    Flexible Benefits
    Commuter Choice Program
    COBRA Administration
    Invoice Reconciliation
    Voluntary Benefits
    Payroll Deduction Benefits
    MasterCash ATM Card
    User Name / Password Problems

  7. #7
    hijink's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2003
    Posts
    2
    Well, my situation is this:

    I have two drop downs. They are for a pick up location and a drop off location.

    Usually the drop off location is the same as the pick up, so I was asked to code it so that once the customer chooses a pick up location the second drop down (the drop off) mirrors the first.

    I'm not that great with javascript (which I have told my employer when they asked me, a lowly secretary, if I could update the website), and especially not great working with arrays. :-/

  8. #8
    coreybryant's Avatar
    Texan at Heart

    Status
    Offline
    Join Date
    Jun 2003
    Location
    Castle Rock, CO
    Posts
    107
    OK.. Let's see. How many drop off locations? And how many pick up locations?

    Is the pick up location related to the drop off location or is the drop off location related to the pick up location?

  9. #9
    coreybryant's Avatar
    Texan at Heart

    Status
    Offline
    Join Date
    Jun 2003
    Location
    Castle Rock, CO
    Posts
    107
    I think this is what you needed?

    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <FORM action="" method=POST id=form1 name=form1>
    <select name="DropOff Location" onChange="document.forms[0].elements['Pickup Location'].selectedIndex=this.selectedIndex">
    <option selected value=""> </option>
    <option value="Orchard Park">Orchard Park</option>
    <option value="Genesee">Genesee</option>
    <option value="Downtown">Downtown</option>
    <option value="Marriott">Marriott</option>
    <option value="Niagara Falls">Niagara Falls</option>
    <option value="Airport">Airport</option>
    </select>

    <select name="Pickup Location">
    <option selected value=""> </option>
    <option value="Orchard Park">Orchard Park</option>
    <option value="Genesee">Genesee</option>
    <option value="Downtown">Downtown</option>
    <option value="Marriott">Marriott</option>
    <option value="Niagara Falls">Niagara Falls</option>
    <option value="Airport">Airport</option>
    </select>


    </FORM>

    </BODY>
    </HTML>

  10. #10
    bdimi's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Posts
    12
    ok, i can do that for a limited number of data...thnx. but if i use a cursor for the select options, since i got data for 500 photographs and i want to use the first drop down menu to select an area so that the second will display the types of memorials (this is what the pics depict) available...is there a way? I dont know much about arrays but from what i can understand, in my case, they would include all the types available for each area...and this is relatively difficult to do...not impossible though...

    thnx again...

  11. #11
    coreybryant's Avatar
    Texan at Heart

    Status
    Offline
    Join Date
    Jun 2003
    Location
    Castle Rock, CO
    Posts
    107
    For 500 items.. I would maybe recommend some type of a database - that way it loads those only when needed. Or even click on a drop down & make it go to a new page. You do not want to have it load too slow



Tags for this Thread