39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<div class="form-group">
|
|
<label for="activityYear">Tahun Aktivitas:</label>
|
|
<div class="input-group">
|
|
<select name="activityYear" id="activityYear" class="form-control">
|
|
@php
|
|
$years = activityYearRange($inventoryYear);
|
|
@endphp
|
|
@foreach ($years as $year)
|
|
<option value="{{ $year }}" {{ $selectedYear == $year ? 'selected' : '' }}>
|
|
{{ $year }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@push('js')
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
$('#inventoryYear').on('change', function() {
|
|
const selectedInventoryYear = parseInt(this.value);
|
|
const $activityYearSelect = $('#activityYear');
|
|
|
|
fetch(`/app/activity_year_range?inventoryYear=${selectedInventoryYear}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
let options = '';
|
|
data.years.forEach(year => {
|
|
options += `<option value="${year}">${year}</option>`;
|
|
});
|
|
$activityYearSelect.html(options).trigger('change');
|
|
})
|
|
.catch(error => console.error('Error fetching year range:', error));
|
|
});
|
|
});
|
|
</script>
|
|
@endpush
|