some minor changes

This commit is contained in:
lukas fricke 2025-01-23 14:28:04 +01:00
parent 57161cbc2d
commit 1c3264f9cb

View file

@ -67,7 +67,7 @@
<label class = "form-label" for="location">Location of Sample</label>
</div>
<div class="col">
<input class="form-control" name="location" value=""></input>
<input class="form-control" name="location" id="Location" value=""></input>
</div>
</div>
<button class="btn btn-primary float-end" type="submit"> submit </button>
@ -76,6 +76,7 @@
</form>
<script>
var map = L.map('map').fitWorld();
var sample_form = document.getElementById("sample");
L.tileLayer(
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
@ -85,7 +86,7 @@
map.on('click', function(ev){
var latlng = map.mouseEventToLatLng(ev.originalEvent);
console.log(latlng.lat + ', ' + latlng.lng);
document.sample.location.value = latlng.lat + ', ' + latlng.lng;
sample_form.location.value = latlng.lat + ', ' + latlng.lng;
if (marker != undefined) {
map.removeLayer(marker);
};
@ -111,11 +112,13 @@
form.addEventListener("submit", add);
function add(event){
event.preventDefault();
let sample = {
"Name" : document.getElementById("Name").value,
"Type" : document.getElementById("Type").value,
"Date_Collected" : document.getElementById("Date_Collected").value,
"Place" : document.getElementById("Place").value,
"Place" : document.getElementById("Location").value,
"Notes" : document.getElementById("Notes").value
}
let transaction = db.transaction(["sample"], "readwrite");
@ -129,7 +132,6 @@
console.log("something went wrong");
// Don't forget to handle errors!
};
event.preventDefault();
}
</script>