How to import data from javascript to html table

Solution 1:

If you are looking for a solution to get the lat and lng then here is how you can get inside the function you are using

   lat = p.coords.latitude;
   lng = p.coords.longitude;

Then you can learn how to insert data in DOM something like this

document.getElementById('latvalue').innerHTML += lat;
document.getElementById('lngvalue').innerHTML += lng;

Solution 2:

You could create a table element and append it to document.body :

// SHOW COORDINATES
if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (p) {
        let table = document.createElement("table");
        table.innerHTML = "<tr><th>Latitude</th><th>Longitude</th></tr><tr><td>" + p.coords.latitude + "</td><td>" + p.coords.longitude + "</td></tr>";
        document.body.appendChild(table);
    });
} else {
    console.log('Geo Location feature is not supported in this browser.');
}