pembuatan basic data surveyor
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
@endpush
|
||||
|
||||
|
||||
<form action="{{ isset($debitur->id) ? route('debitur.update', $debitur->id) : route('debitur.store') }}" method="POST"
|
||||
<form id="debiturForm" action="{{ isset($debitur->id) ? route('debitur.update', $debitur->id) : route('debitur.store') }}" method="POST"
|
||||
class="grid gap-5">
|
||||
@if (isset($debitur->id))
|
||||
<input type="hidden" name="id" value="{{ $debitur->id }}">
|
||||
@@ -478,6 +478,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2" style="margin-right: 20px; margin-top: 20px">
|
||||
<button type="submit" class="btn btn-success">
|
||||
Save
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
@@ -521,4 +530,71 @@
|
||||
window.onload = getUserLocation;
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// Fungsi untuk menyimpan data ke localStorage saat ada perubahan input
|
||||
|
||||
|
||||
const formElement = document.getElementById('debiturForm');
|
||||
|
||||
// Mengambil nilai dari localStorage saat halaman dimuat
|
||||
window.onload = () => {
|
||||
const storedData = localStorage.getItem('debiturData');
|
||||
if (storedData) {
|
||||
const formData = JSON.parse(storedData);
|
||||
// Mengisi nilai untuk elemen select
|
||||
for (const [key, value] of Object.entries(formData)) {
|
||||
const inputElement = formElement.querySelector(`[name="${key}"]`);
|
||||
if (inputElement) {
|
||||
if (inputElement.tagName === 'SELECT') {
|
||||
inputElement.value = value; // Atur nilai select
|
||||
} else if (inputElement.type === 'radio') {
|
||||
const radioButton = document.getElementById(`${key}${value.charAt(0).toUpperCase() + value.slice(1)}`);
|
||||
if (radioButton) {
|
||||
radioButton.checked = true; // Atur radio button yang sesuai sebagai checked
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Simpan data ke localStorage dalam bentuk JSON
|
||||
formElement.addEventListener('change', () => {
|
||||
const formData = {};
|
||||
const inputs = formElement.querySelectorAll('input, select');
|
||||
|
||||
inputs.forEach(input => {
|
||||
if (input.type === 'radio' && input.checked) {
|
||||
formData[input.name] = input.value; // Hanya ambil nilai radio yang terpilih
|
||||
} else if (input.type !== 'radio') {
|
||||
formData[input.name] = input.value; // Ambil nilai dari elemen lain
|
||||
}
|
||||
});
|
||||
|
||||
localStorage.setItem('debiturData', JSON.stringify(formData)); // Simpan objek sebagai JSON
|
||||
});
|
||||
|
||||
// Opsi: Reset localStorage saat form disubmit
|
||||
formElement.onsubmit = () => {
|
||||
localStorage.removeItem('debiturData'); // Menghapus data spesifik dari localStorage
|
||||
};
|
||||
|
||||
|
||||
// Opsi: Reset localStorage saat form disubmit
|
||||
document.getElementById('debiturForm').onsubmit = (event) => {
|
||||
event.preventDefault(); // Mencegah pengiriman form
|
||||
|
||||
// Menyimpan semua input ke localStorage
|
||||
inputs.forEach(input => {
|
||||
localStorage.setItem(input.name, input.value);
|
||||
});
|
||||
|
||||
// Opsional: Tampilkan pesan bahwa data telah disimpan
|
||||
alert('Data telah disimpan ke localStorage!');
|
||||
|
||||
// Jika ingin menghapus localStorage, uncomment baris di bawah
|
||||
// localStorage.clear();
|
||||
};
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<option value="">Select Hadap Mata Angin</option>
|
||||
@if (isset($arahMataAngin))
|
||||
@foreach ($arahMataAngin as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -56,7 +56,7 @@
|
||||
<option value="">Select Bentuk Tanah</option>
|
||||
@if (isset($bentukTanah))
|
||||
@foreach ($bentukTanah as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -76,7 +76,7 @@
|
||||
<option value="">Select Kontur Tanah</option>
|
||||
@if (isset($konturTanah))
|
||||
@foreach ($konturTanah as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -98,7 +98,7 @@
|
||||
<option value="">Select Ketinggian Dengan Jalan</option>
|
||||
@if (isset($ketinggianTanah))
|
||||
@foreach ($ketinggianTanah as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -142,7 +142,7 @@
|
||||
<option value="">Select Posisi Kavling</option>
|
||||
@if (isset($posisiKavling))
|
||||
@foreach ($posisiKavling as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -207,7 +207,7 @@
|
||||
<option value="">Select Posisi Kavling</option>
|
||||
@if (isset($kondisiFisikTanah))
|
||||
@foreach ($kondisiFisikTanah as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -258,7 +258,7 @@
|
||||
<option value="">Select Jenis Bangunan</option>
|
||||
@if (isset($jenisBangunan))
|
||||
@foreach ($jenisBangunan as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -279,7 +279,7 @@
|
||||
<option value="">Select Kondisi Bangunan</option>
|
||||
@if (isset($kondisiBangunan))
|
||||
@foreach ($kondisiBangunan as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -300,7 +300,7 @@
|
||||
<option value="">Select Sifat Bangunan</option>
|
||||
@if (isset($sifatBangunan))
|
||||
@foreach ($sifatBangunan as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
<option value="{{ $item->name }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -330,7 +330,7 @@
|
||||
@if (isset($spekBangunan))
|
||||
@foreach ($spekBangunan as $spek)
|
||||
@if ($spek->spek_kategori_bagunan_id == $item->id)
|
||||
<option value="{{ $spek->id }}">{{ $spek->name }}
|
||||
<option value="{{ $spek->name }}">{{ $spek->name }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
Reference in New Issue
Block a user