Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem with second dropdown list

Newbie
 
Join Date: Feb 2008
Posts: 11
#1: Mar 13 '08
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=\"reload(this.form)\"><option value=''>Client</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['client_id']==@$cat){echo "<option selected value='$noticia2[client_id]'>$noticia2[client]</option>"."<BR>";}
else{echo "<option value='$noticia2[client_id]'>$noticia2[client]</option>";}
}
echo "</select>";

// This will end the first drop down list

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

?>
</td>
</tr>
<tr>
<td class="label">Tuesday :</td>
<td class="field">
<?
echo "<select name='Tuesday'><option value=''></option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[hours]'>$noticia[hours]</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td class="label">Wednesday :</td>
<td class="field">
<?
echo "<select name='Wednesday'><option value=''></option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[hours]'>$noticia[hours]</option>";
}
echo "</select>";
// etc .......
[/php]

Newbie
 
Join Date: Mar 2008
Posts: 3
#2: Mar 19 '08

re: Problem with second dropdown list


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.selectedValue"

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.
Reply