Execute an html script from a form


I need to capture and save the latitude and longitude of a mobile users position and save them to fields of my table. I have html code working fine to perform the function but have no idea how I can execute the script within a form and capture the data to the fields. Any creative ideas would be appreciated.

You are using DaDaBIK version 10.3-Manarola enterprise, installed on 10-31-2020
You are runnning the last release of DaDaBIK
System info
PHP Version: 7.4.3
mysql version: 8.0.22-0ubuntu0.20.04.2
Web server: Apache/2.4.41 (Ubuntu)
Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36


Staff member
I think you should add a custom button, choosing "javascript" as type and add your custom code to the related function.



That did not work

Here is a better description with ALL of the details

I have a table in dadabik called 'geo'

It has fields for name, user id, time date stamp, latitude and longitude (and some other fields).

I have a javascript file called 'geoloc.js' which retrieves the users latitude and longitude from their device.
Stand-alone, called from an index.php page,
It works fine as a 'stand-alone" function (outside of dadabik).

geoloc.js code:

(function() {
window.onload = getLocation;

var geo = navigator.geolocation;

function getLocation() {

if (geo) {

} else {
alert("Geolocation API is not supported");

function displayLocation(position) {
var lat = position.coords.latitude;

var lang = position.coords.longitude;

document.getElementById('txtlat').value = lat;

document.getElementById('txtlang').value = lang;


I then can externally insert the latitude and longitude into the table with no problem.
The external insertdb.php code is:

$con = mysqli_connect("localhost", "user", "pw", "dbname");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
$latitude = $_REQUEST['txtlat'];
$longitude = $_REQUEST['txtlang'];
$name = $_REQUEST['txt_name'];
$dob = $_REQUEST['txt_dob'];
$state = $_REQUEST['txt_state'];
$city = $_REQUEST['txt_city'];
$phn = $_REQUEST['txt_phno'];
$zip = $_REQUEST['txt_zip'];
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if (isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if (isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if (isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if (isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
$ipaddress = 'UNKNOWN';
$ip = $ipaddress;
$SLNO = "100001";
$sqlres = "select MAX(id) from `geo`";
if ($result = mysqli_query($con, $sqlres)) {
if ($row = mysqli_fetch_array($result)) {
if ($row[0] != "") {
$SLNO = $row[0] + 1;
} $now = date("Y-m-d H:i:s");
mysqli_query($con, "INSERT INTO `geo` (`id`,`sdate`,`lat`,`long`,`ip_add`,`name`,`DOB`,`state`,`city`,`phone_no`,`zip`) VALUES ('$SLNO','$now','$latitude','$longitude','$ip','$name','$d>

echo "Data Saved Successfully";

echo '<form><input type="button" value="Return to previous page" onClick="javascript:history.go(-2)"></form>';

How can i perform this function from within my dadabik form page?
I do not want to launch an external page for this function.
I just want to grab the lat and long using my geoloc.js script and insert the
values retrieved into my latitude and longitude fields of my form.
(should not be any need to use my external insertdb.php code)