CHANGE_STAFF_FORM : AADHAVAN

This commit is contained in:
unknown 2024-06-15 09:46:45 +05:30
parent 5e2b80c086
commit 554beba684
2 changed files with 23 additions and 40 deletions

View File

@ -51,7 +51,7 @@
<div class="form-group col-md-4">
<label for="business">Business<span class="text-danger">*</span></label>
<select class="form-control business slect2_dropdown" id="business_id" name="business_id" parsley-trigger="change" required >
<select class="form-control slect2-dropdown" id="business_id" name="business_id" parsley-trigger="change" required >
<option >Select Business</option>
<?php foreach ($business as $key => $value) { ?>
<option value="<?php echo $value['business_id']; ?>" <?php if(isset($staffData)){ echo ($staffData->business_id == $value['business_id']) ? 'selected' : '';} ?>>
@ -62,7 +62,7 @@
</div>
<div class="form-group col-md-4">
<label for="branch">Branch<span class="text-danger">*</span></label>
<select class="form-control branch slect2_dropdown" id="branch_id" name="branch_id" parsley-trigger="change" required >
<select class="form-control slect2-dropdown" id="branch_id" name="branch_id" parsley-trigger="change" required >
<option >Select Branch</option>
<?php if(isset($staffData)){ foreach ($branch as $key => $value) { ?>
<option value="<?php echo $value['branch_id']; ?>" <?php echo ($staffData->branch_id == $value['branch_id']) ? 'selected' : ''; ?>>
@ -183,52 +183,35 @@
<script>
$(document).ready(function() {
// $('.slect2_dropdown').select2();
// $('.branch').select2();
});
$('.slect2-dropdown').select2();
$('#business_id').change(function (params) {
var business_id = $(params.target).val();
if (business_id) {
var branch_list = <?php echo json_encode($branch); ?>;
// Clear existing options or elements if needed
// $('.branch').empty(); // Clear previous options
// Filter branch_list based on business_id
var filteredBranches = branch_list.filter(function(element) {
return element.business_id == business_id;
});
// $('.branch').append("<option>Select Branch</option>");
// Append filtered branches to the select dropdown or another container
// filteredBranches.forEach(function(branch) {
$('#branch_id').empty();
$("#business_id").on("change", function() {
var business_id = $(this).val();
if (business_id) {
var branch_list = <?php echo json_encode($branch); ?>;
// Filter branch_list based on business_id
var filteredBranches = branch_list.filter(function(element) {
return element.business_id == business_id;
});
$('#branch_id').empty();
$('#branch_id option:not(:first)').remove();
$('#branch_id').append($('<option>', {
text: "Select Branch"
}));
text: "Select Branch"
}));
$.each(filteredBranches, function(index, item) {
console.log(item);
$('#branch_id').append($('<option>', {
value: item.branch_id,
text: item.branch_name
value: item.branch_id,
text: item.branch_name
}));
});
// Create an <option> element for each branch
// var option = $('<option>').val(branch.branch_id).text(branch.branch_name);
// Append the option to the select dropdown
// $('.branch').append(option);
// });
// Optional: Trigger change event after appending options
// $('.branch').trigger('change');
}
}
});
});
</script>

View File

@ -3,7 +3,7 @@
'name' => 'codeigniter4/framework',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'b5cb4a5de15965151f25bc2688ec1a2bac8fa319',
'reference' => '5e2b80c08689c74422d2cbd8cdc949108768d74a',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -31,7 +31,7 @@
'codeigniter4/framework' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'b5cb4a5de15965151f25bc2688ec1a2bac8fa319',
'reference' => '5e2b80c08689c74422d2cbd8cdc949108768d74a',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),