I have three combo boxes
First one displays contains 3 values (a) School Studies b) intermediate c) professinal studies
and if user selects any one i have used onchange to submit the form
Based on the value submitted i retrive classes information from database like
if (a) then 6th class, 7th class like that
if(b) 11 th , 12 class
if (c) computers, electronics like that
for this again i used another combo box
like that based on the selected class i have to show subjects of specific class
Every thing is working fine
But if i change the first combo box suddenly then remaining combo boxes should become invisible as i have changed the value of first combo box then relatively classes and subjects information should be changed but its not getting .
please help
Code: Select all
<table width="150">
<tr>
<td align="left" class="style31">Category</td>
<td align="right" class="style31"><select name="cat" class="style31"
onchange="submit();">
<option value="">
<--------Select--------> </option><?php include("dbconn.php");
$result = mysql_query("select * from dg_category");
while($row = mysql_fetch_array($result))
{?>
<option value=
"<?php echo $row[0]; ?>" <?php
if(strcmp($_POST['cat'],$row[0]) == 0)
{
echo "selected";
}//if
?>>
<?php echo $row[1]; ?> </option><?php
}//while
?>
</select></td>
</tr>
<?php
if($_POST['cat'])
{ ?>
<tr>
<td align="left" class="style31">
class/Specialization</td>
<td align="right">
<select name="class1" class="style31"
onchange="submit();">
<option value="">
<--class--> </option><?php $cat = $_POST['cat'];
$result = mysql_query("select * from dg_class where category_id ='$cat'");
while($row = mysql_fetch_array($result))
{?>
<option value=
"<?php echo $row[0]; ?>" <?php
if(strcmp($_POST['class1'],$row[0]) == 0)
{
echo "selected";
}//if
?>>
<?php echo $row[1]; ?> </option><?php
}//while
?>
</select> </td>
</tr>
<?php
}
else { $_POST['class1'] = NULL;} ?> <!--if category -->
<?php
if($_POST['class1'])
{ ?>
<tr>
<td class="style31"><div align="left">SessionTimings</div></td>
<td><div align="right">
<select name="session" class="style31" onchange="submit();">
<option value=""><---select---></option>
<option value="1"
<?php if($_POST['session'] == 1)
echo "selected";
?>>Morning(6AM - 2PM)</option>
<option value="2"
<?php if($_POST['session'] == 2)
echo "selected";
?>>Evening(2PM - 10PM)</option>
</select>
</div></td>
</tr>
<?php
}
else
{
$_POST['session'] =NULL ;
}
?>
<?php
if($_POST['session'])
{ ?>
<tr>
<td align="left" class="style31">subject</td>
<td align="right">
<select name="sub" class="style31" onchange="submit()">
<option value="">
<--Subject--> </option><?php $class = $_POST['class1'];
$result = mysql_query("select * from dg_subject where class_id ='$class'");
while($row = mysql_fetch_array($result))
{?>
<option value=
"<?php echo $row[0]; ?>" <?php
if(strcmp($_POST['sub'],$row[0]) == 0)
{
echo "selected";
}?>> <!--if -->
<?php echo $row[1]; ?> </option><?php
}?> <!--while -->
</select> </td>
</tr>
<?php }
else
{
$_POST['sub'] = NULL;
} ?>
<?php if($_POST['sub'])
{?>
<tr class="style31">
<td colspan="2">
<table border="1">
<tr>
<th colspan="4" align="center" width="300" class="style31">Topics</th>
</tr>
<?php
$sub = $_POST['sub'];
$result = mysql_query("select * from dg_subject_topic where subject_id ='$sub'");
if( mysql_num_rows($result) <= 0)
{?>
<tr>
<td colspan="4" align="center">
NO Topics </td>
</tr> <?php
}
else
{?>
<tr>
<td width="35">Select</td>
<td width="134">TopicName</td>
<td width="32">Cost</td>
<td width="48">Duration</td>
</tr><?php
while($row = mysql_fetch_array($result))
{?>
<tr>
<td align="left"><input type="radio" name="list" id="list"
value="<?php echo $row[0];?>"
<?php if($_POST['list'] == $row[0])
{
echo "checked";
} ?>/> </td>
<td align="left"><?php
echo $row[1]; ?> </td>
<td align="left"><?php
echo $row[4]; ?> </td>
<td align="left"><?php
$duration = $row[3];
$_SESSION['duration'] = $duration;
echo $row[3]; ?> </td>
</tr><?php
}// while ?>
<tr>
<td class="style31" colspan="4" align="center">
<input type="hidden" name="hid" id="hid" value=
"<?php if($_POST['cat']) { echo $_POST['hid']; } ?>" /> <a href="javascript:document.sstw.submit()"
onclick="submitform1('1','hid'); ">submit</a> </td>
</tr>
</table> </td>
</tr>
<?php } // else
}
else
{
$_POST['hid'] = NULL;
} //if (sub) ?>
</table>