i want to populate second combo box based on valure selected in first combo- both the combo box values will be retrieved from database using php
<div class="col-12"><br>
<label class="form-label">Category*</label>
<select class="form-control" name="category" id="category">
<option disabled="disabled" selected="selected">Choose option</option>
<?php
$q="SELECT DISTINCT category FROM `categorylist` ORDER BY category asc";
$r = mysqli_query($connection, $q);
while ($row = mysqli_fetch_array($r)) {
$dropdown=$row['category'];
echo "<option value='$dropdown'>$dropdown</option>";
}
?>
</select>
</div>
<div class="col-12"><br>
<label class="form-label">subCategory*</label>
<select class="form-control" name="subcategory" id="subcategory">
<option disabled="disabled" selected="selected">Choose option</option>
<?php
$q1="SELECT DISTINCT subCategory FROM `categorylist` ORDER BY subCategory asc";
$r1 = mysqli_query($connection, $q1);
while ($row = mysqli_fetch_array($r1)) {
$dropdown=$row['subCategory'];
echo "<option value='$dropdown'>$dropdown</option>";
}
?>
</select>
source https://stackoverflow.com/questions/70137004/i-want-to-populate-second-combo-box-based-on-valure-selected-in-first-combo-bot
Comments
Post a Comment