Problem with second dropdown list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bobf
    New Member
    • Feb 2008
    • 11

    Problem with second dropdown list

    I have successfully linked 2 dropdown lists, but then I got greedy and wanted to provide the same information to further dropdown boxes.
    What I am trying to do is to select a client and then offer daily shifts dependent on the client selected.
    I can only still get the first box (Monday) to subsequently open. Can you see what I am doing wrong and possible come up with a solution.
    Code: [php]
    // Starting of first drop downlist

    echo "<select name='cat' onchange=\"relo ad(this.form)\" ><option value=''>Client </option>";
    while($noticia2 = mysql_fetch_arr ay($quer2)) {
    if($noticia2['client_id']==@$cat){echo "<option selected value='$noticia 2[client_id]'>$noticia2[client]</option>"."<BR>" ;}
    else{echo "<option value='$noticia 2[client_id]'>$noticia2[client]</option>";}
    }
    echo "</select>";

    // This will end the first drop down list

    ?>
    <tr>
    <td class="label">M onday :</td>
    <td class="field">
    <?
    echo "<select name='Monday'>< option value=''></option>";
    while($noticia = mysql_fetch_arr ay($quer)) {
    echo "<option value='$noticia[hours]'>$noticia[hours]</option>";
    }
    echo "</select>";

    ?>
    </td>
    </tr>
    <tr>
    <td class="label">T uesday :</td>
    <td class="field">
    <?
    echo "<select name='Tuesday'> <option value=''></option>";
    while($noticia = mysql_fetch_arr ay($quer)) {
    echo "<option value='$noticia[hours]'>$noticia[hours]</option>";
    }
    echo "</select>";
    ?>
    </td>
    </tr>
    <tr>
    <td class="label">W ednesday :</td>
    <td class="field">
    <?
    echo "<select name='Wednesday '><option value=''></option>";
    while($noticia = mysql_fetch_arr ay($quer)) {
    echo "<option value='$noticia[hours]'>$noticia[hours]</option>";
    }
    echo "</select>";
    // etc .......
    [/php]
  • logicsachin
    New Member
    • Mar 2008
    • 3

    #2
    Hi,

    If I have understood your problem clearly, you want to list the options of the third drop-down list based on the selection values made by the first two drop down lists. Please use better commenting in your code for us to understand it better.

    One solution is to create a hidden field in form2 and when you reload form1, the hiddent text field in form2 should be filled with value like "form1.selected Value"

    this form variable can be posted again using 'post' method when you submit form2. So when form2 is submitted, the following two variables are submitted

    1. selection from 2nd dropdown list
    2. selected value from form1 (saved in the hidden field) - identified by the name of the hidden field.

    see if you understand this.

    Comment

    Working...