Creating a dynamic drop down menu

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpnewbie2007
    New Member
    • Jun 2007
    • 4

    Creating a dynamic drop down menu

    I have 2 dynamic PHP dropdowns:

    The second dropdown populates from the first, depending on what is selected in the first.
    The page is showing issues in a department:

    The first dropdown consists of departments- It has 3 options All issues, dept A, dept B
    If dept A is chosen in the first dropdown, the second dropdown shows all members in dept A and all issues are shown for dept A are shown below.

    Now if i choose a member in second dropdown, i want issues owned by this member to show up.

    code:
    [code=php]
    <?php

    //db connection file goes here



    if (isset($_GET["first"]))
    {
    $first =$_GET["first"];


    }
    if (isset($_GET["second"]))
    {
    $second =$_GET["second"];

    }

    ?>
    <HTML>

    <script language="JavaS cript">

    function mySubmit()
    {
    var formObject = document.forms['myform'];
    formObject.subm it();
    }


    <?php

    </HEAD>
    <BODY>

    <form name="myform" method="get">

    <p>Please select a dept
    <select name="first" onChange ="mySubmit() ;">
    <option value="NULL"></option>
    <?php
    //get members from db depending on what dept is selected

    echo '</SELECT>';

    if($first != null)
    {

    ?>
    Please select a member:&nbsp;
    <select name="second" onChange="mySub mit();">

    //get option values from db
    echo '</SELECT>';

    }

    //if dept selected show issues for that dept
    //if member selected show issues only for that member


    </TABLE>
    </BODY>
    </HTML>
    [/code]

    Any help is appreciated.

    Thank you.
    Last edited by Atli; Aug 25 '07, 12:45 AM. Reason: Added [php] tags
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, PHP Newbie.

    There are over a dozen threads on this site that cover exactly what you are looking for.

    Head over to the search page and search the PHP forum for 'dynamic drop down'.

    Comment

    Working...