Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Bunbury W.A
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Dynamic Dropdown menu problem HELP

    Hi All Im getting a bit desperate here so have posted again, as I recieved no help.
    I am using the following code in my pages to populate a 2 drop down menus, I cant work out how to get this code to goto the page the choice selects. in the bottom drop down menu.
    The code is as follows


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>
    </head>

    <body>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Cascading dropdown lists</title>
    </head>

    <body>

    <h3>Cascading dropdowns</h3>
    Welcome to the wonderful world of cascading dropdowns.
    Select a country and the dropdown below will be populated with a selection of regions
    <hr>

    <script language='javascript'>

    //Author: Paul Berry - PBerry@CirrusSoftware.com
    //Date: July 2002
    //Licence: Its Freeware!... Just leave my name against the code and send me a mail if you like.
    //Purpose: Provides simple dropdown functionality that could be used on multiple cascading dropdown lists.
    //Compatability: This process will work on both IE and Netscape (tested on Ns 4.5 and IE 5.5)

    var iArrayMax = 16
    var aDropdown = new Array(iArrayMax)

    //as the page loads - first thing to do is to load the dropdown array
    var bOk = LoadArrays()

    function LoadArrays()
    {
    //this can be thought of as an object array, each element can be identified as a property of the array position
    // a very powerful structure for 'client side' data caching.
    Array[0] = new sElement('UK','En','England')
    Array[1] = new sElement('UK','Ir','Ireland')
    Array[2] = new sElement('UK','Sc','Scotland')
    Array[3] = new sElement('UK','Wa','Wales')
    Array[4] = new sElement('UK','Ia','Isle of Arran')

    Array[5] = new sElement('USA','Ny','New York')
    Array[6] = new sElement('USA','Il','Illinois')
    Array[7] = new sElement('USA','Fl','Florida')
    Array[8] = new sElement('USA','Nm','New Mexico')
    Array[9] = new sElement('USA','Tx','Texas')
    Array[10] = new sElement('USA','Se','Seattle')
    Array[11] = new sElement('USA','NJ','New Jersey')
    Array[12] = new sElement('USA','VT','Vermont')
    Array[13] = new sElement('USA','AZ','Arizona')
    Array[14] = new sElement('USA','NH','New Hampshire')
    Array[15] = new sElement('USA','MI','Missouri')
    Array[16] = new sElement('USA','NE','New England')
    Array[17] = new sElement('USA','PA','Pennsylavania')
    Array[18] = new sElement('USA','Se','Seattle')





    return true
    }

    function sElement(sParentId,sValue,sDescription)
    {
    // elements that will be loaded into the array structure and persisted
    // think of it as an object.
    this.ParentId = sParentId
    this.Id = sValue
    this.Description = sDescription
    }

    function bCascadeDrop(oDDsource,oDDdest)
    {
    //function to enable cascading dropdowns
    //called as the parent dropdown changes.
    var iX
    var sText
    var iY= 0
    var sOptionId
    var sOptionDesc
    var iStartPos

    //find the value of the item currently selected
    sText = oDDsource.options[oDDsource.selectedIndex].value
    if (sText != '0')
    {
    //clear down the destination list box
    oDDdest.options.length = 0

    //loop through the elements that are in the array
    // if they match the parent if then they should be displayed.
    for (iX=0; iX<=iArrayMax; iX++)
    {
    if(sText == Array[iX].ParentId)
    {
    //grab the values out of the element (Netscape is not happy doing too many things in a function call!)
    sOptionId = Array[iX].Id
    sOptionDesc= Array[iX].Description
    //alert(sOptionDesc)

    //write the element into the dripdown box.
    oDDdest.options[iY] = new Option (sOptionDesc,sOptionId)
    iY = iY +1
    }
    }
    }
    }
    </script>

    <form action="FrmNew">
    <table>
    <tr>
    <td>Country</td>
    <td>
    <select style="width=150" name="sCountry" onChange="bCascadeDrop(this, document.forms[0].sRegion)">
    <option value="0" SELECTED> - None selected - </option>
    <option value="UK" > United Kingdom</option>
    <option value="USA">America</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>Region</td>
    <td>
    <select name="sRegion" style="width=150">
    <option value="0" SELECTED> - None selected - </option>
    </select>
    </td>
    </tr>

    </table>
    </form>
    </body>
    </html>



    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What page the "choice" selects. You have no pages referenced at all in your code. It looks to me like you took some code to populate one select from a selection made in another select but that doesn't make the selects into navigation.

  • #3
    Regular Coder
    Join Date
    May 2002
    Location
    Seattle, WA
    Posts
    665
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Bunbury W.A
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ohhh Thank you

    Thanks speedracer thats it. bloody marvelous


  •  

    Posting Permissions

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