I have two dropdown boxes and what I want to do is when I select from the 1st dropdown the value of the 1st dropdown will be able to get by the 2nd dropdown so it will be the basis of the 2nd dropdown to its query.
<tr>
<td><div class="captionbold">OR Book Type</div></td>
<td colspan="3"><div align="left">
<span class="custom-dropdown custom-dropdown--white custom-dropdown--small">
<select class="custom-dropdown__select custom-dropdown__select--white" name="txtorbooktype" style="width:220px;">
<option>-</option>
<option value='0' <?php if($txtorbooktype=='0'){echo 'selected';} ?>>
Real Property Tax Administration System</option>
<option value='1' <?php if($txtorbooktype=='1'){echo 'selected';} ?>>
Business Permit and Licensing</option>
<option value='2' <?php if($txtorbooktype=='2'){echo 'selected';} ?>>
Others Transaction</option>
</select>
</span>
</div></td>
</tr>
<tr>
<td><div class="captionbold">OR Book</div></td>
<td><div align="left">
<span class="custom-dropdown custom-dropdown--white custom-dropdown--small">
<select class="custom-dropdown__select custom-dropdown__select--white" name="txtorbookfromto" style="width:200px;">
<?php
$sql = "SELECT orbookcode, concat(orbookfrom,' - ',orbookto) as orbookfromto FROM rorbookinfo where orbooktype = '".$_POST['txtorbooktype']."' and status = '0'";
include_once rootpathphp.'/lib/config.php';
$con = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_DATABASE);
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"ajax_demo");
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($result))
{
$default = '';
if($row['orbookcode']==$txtorbookfromto)
{
$default = 'selected';
}
echo $default;
echo " <option ".$default." value='".$row['orbookcode']."'>".$row['orbookfromto']."</option>";
}
mysqli_close($con);
?>
</select>
</span>
</div></td>
</tr>