I want to achieve after selecting in my select tag, it will display a input tag in my modal and that has been fetch in other table in database.
totalfees.php
if(isset($_POST["year"]))
{
$output = '';
$query = "SELECT total_fees FROM manage_fees WHERE year_lvl = '".$_POST["year"]."'";
$result = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($result))
{
$output .= '
<input type="text" class="form-control" id="tf" name="tf" readonly="readonly" value="'.$row["total_fees"].'">
';
}
echo $output;
}
gettotal.js
$(document).ready(function(){
$('#year').click(function(){
var year = $(this).attr("year");
$.ajax({
url:"../include/assessment.php",
method:"post",
data:{year:year},
success:function(data){
$('#total_fees').html(data);
}
});
});
assessment.php
<div class="modal fade" id="fee_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Assess Student</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form method="POST" action="officer_studentAssessment.php" id="reg">
<div class="form-group">
<label for="year">Year</label>
<select class="form-control" id="year" name="year" required>
<?php
$result = $connect->query("SELECT * FROM year_lvl") or die($connect->error());
while($row = $result->fetch_assoc()):
?>
<option value="<?php echo $row['year']; ?>"><?php echo $row["year"]; ?></option>
<?php endwhile; ?>
</select>
</div>
<div class="form-group" id="total_fees">
<label for="tf">Total fees</label>
</div>
<div class="modal-footer">
<button class="btn btn-success" name="create" id="create" type="submit">Create</button>
</div>
</form>
</div>
</div>
</div>
</div>
in totalfees.php the output should be display on the DIV tag where id = total_fees, the problem is after I click the select tag the DIV disappears
<div class="form-group" id="total_fees">
<label for="tf">Total fees</label>
</div>