SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    ireland
    Posts
    482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Drop Down problem can't figure it out

    Hi

    I have 3 drop down lists depending on what you select in the first drop down, will determine what drop down is displayed, ie when option from dropdown 1 is selected dropdown 2 or 3 will be displayed depending on what option was selected in dropdown 1. Do I need javascript or caqn it be done without. Really coming near to my deadlone and can't figure this out. Also if this helps the dropdowns are pulling from a mysql database.

    Tks in advance


    ------------Dropdown 1---------------


    echo'<table align="center">';

    if(isset($_POST['secondary_exam_id']))

    $_SESSION['secondary_exam_id']=$_POST['secondary_exam_id'];

    echo'<tr>
    <td colspan="2" class="labelcell">
    <label for="secondary_exam_id">* Select Curriculum/label></td>';

    echo'<td colspan="2" class="fieldcell2">

    <select name="secondary_exam_id">';

    $query_result = mysql_query ('SELECT * FROM secondary_exam_type ORDER BY secondary_exam_id');

    while ($row = mysql_fetch_array ($query_result, MYSQL_NUM))
    {
    if($row[0] == $_SESSION['secondary_exam_id'])
    {
    $checked = 'selected';
    }
    else
    {
    $checked = NULL;
    }

    echo "<option value=\"$row[0]\" $checked>$row[1]</option>\n";
    }

    echo'</select></td>';
    echo'</tr>';


    ------------Dropdown 2---------------



    if(isset($_POST['junior_subject_id']))

    $_SESSION['junior_subject_id']=$_POST['junior_subject_id'];

    echo'<tr>
    <td colspan="2" class="labelcell">
    <label for="junior_subject_id">* Select Junior Subject/label></td>';

    echo'<td colspan="2" class="fieldcell2">

    <select name="junior_subject_id">';

    $query_result = mysql_query ('SELECT * FROM junior_subjects ORDER BY junior_subject_id');

    while ($row = mysql_fetch_array ($query_result, MYSQL_NUM))
    {
    if($row[0] == $_SESSION['junior_subject_id'])
    {
    $checked = 'selected';
    }
    else
    {
    $checked = NULL;
    }

    echo "<option value=\"$row[0]\" $checked>$row[1]</option>\n";
    }

    echo'</select></td>';
    echo'</tr>';




    ------------Dropdown 3---------------



    if(isset($_POST['leaving_subject_id']))

    $_SESSION['leaving_subject_id']=$_POST['leaving_subject_id'];

    echo'<tr>
    <td colspan="2" class="labelcell">
    <label for="leaving_subject_id">* Select leaving Subject/label></td>';

    echo'<td colspan="2" class="fieldcell2">

    <select name="leaving_subject_id">';

    $query_result = mysql_query ('SELECT * FROM leaving_subjects ORDER BY leaving_subject_id');

    while ($row = mysql_fetch_array ($query_result, MYSQL_NUM))
    {
    if($row[0] == $_SESSION['leaving_subject_id'])
    {
    $checked = 'selected';
    }
    else
    {
    $checked = NULL;
    }

    echo "<option value=\"$row[0]\" $checked>$row[1]</option>\n";
    }

    echo'</select></td>';
    echo'</tr>';

  2. #2
    SitePoint Addict mx2k's Avatar
    Join Date
    Jan 2005
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you'll need some kind of client side script or submit button in order to do a post back

  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    ireland
    Posts
    482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you point me in the direction of some code that might be suitable.

    Tks

  4. #4
    SitePoint Addict mx2k's Avatar
    Join Date
    Jan 2005
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will need to use JavaScript if you want to have all of the drop-down menus on one page, however if you have submit buttons linking to multiple pages with a new drop-down menu on each page you should be able to accomplish what you need. Just remember to send the user-submitted information to the next page.


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
  •