html code for form
<form action="code.php" method="POST" enctype="multipart/form-data">
<div class="form-group col-md-12 mb-2">
<label for="fname" class="form-label">Select District Name<span class="font-weight-bold text-danger">*</span></label>
<select id="dist" name="distcode" class="form-select" require>
<option class="active">Select District Name</option>
<?php
include '../mysqli_connect.php';
$sql = "SELECT * FROM tb_district";
$result = $con->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
?>
<option value="<?php echo $row['dist_code']; ?>"><?php echo $row['dist_name']; ?></option>";
<?php
}
}
?>
</select>
</div>
<div class="form-group col-md-12 mb-2">
<label for="fname" class="form-label">Select Block Name<span class="font-weight-bold text-danger">*</span></label>
<select id="block" name="blockname" class="form-select">
<option class="active">Select Block Name</option>
</select>
</div>
<div class="form-group col-md-12 mb-3">
<label for="fname" class="form-label">Select Panchayat Name<span class="font-weight-bold text-danger">*</span></label>
<select id="panchayat" name="panchayatname" class="form-select">
<option class="active">Select Panchayat</option>
</select>
</div>
<div class="form-group col-md-12 mb-2">
<label for="fname" class="form-label">USERID<span class="font-weight-bold text-danger">*</span></label>
<input type="text" class="form-control" id="panchayat" name ="blockcode" readonly >
</div>
<div class="form-group col-md-12">
<button type="submit" name="save_excel_data" class="btn btn-primary mt-3">Import</button>
</div>
</form>
And the Javascript for load dependent dropdown list is
$('#dist').click(function() {
//Get selected Country ID
var distid = $(this).val();
$.ajax({
type : 'POST',
url : '../adddistblockpanchayat/load-distblockajax.php',
data : 'dist='+distid, //pass country data
success : function(data) {
$('#block').html(data);
}
});
});
$('#block').click(function() {
//Get selected Country ID
var blockid = $(this).val();
$.ajax({
type : 'POST',
url : '../adddistblockpanchayat/load-distblockajax.php',
data : 'block='+blockid, //pass country data
success : function(data) {
$('#panchayat').html(data);
}
});
});
now I want to combine the value of the dependent dropdown and display this is a textbox.