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