git add .
git commit "fix: city selection, comment user display, and back button bug"
This commit is contained in:
@@ -570,5 +570,42 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const provinceSelect = document.getElementById('province_id');
|
||||
const citySelect = document.getElementById('city_id');
|
||||
|
||||
provinceSelect.addEventListener('change', function () {
|
||||
const provinceId = this.value;
|
||||
|
||||
citySelect.innerHTML = '<option value="">در حال بارگذاری...</option>';
|
||||
citySelect.disabled = true;
|
||||
|
||||
if (!provinceId) {
|
||||
citySelect.innerHTML = '<option value="">ابتدا استان را انتخاب کنید</option>';
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`{{ url('/cities') }}/${provinceId}`)
|
||||
.then(response => response.json())
|
||||
.then(cities => {
|
||||
citySelect.innerHTML = '<option value="">انتخاب شهرستان</option>';
|
||||
|
||||
cities.forEach(city => {
|
||||
const option = document.createElement('option');
|
||||
option.value = city.id;
|
||||
option.textContent = city.name;
|
||||
citySelect.appendChild(option);
|
||||
});
|
||||
|
||||
citySelect.disabled = false;
|
||||
})
|
||||
.catch(() => {
|
||||
citySelect.innerHTML = '<option value="">خطا در دریافت شهرها</option>';
|
||||
citySelect.disabled = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user