Forums

Saving Google Maps coordinates

flyboeing 28 May, 2013
Hello all,

For my website I am trying to make a form where people can locate there homes using a Google Maps map with a draggable marker. After submitting the form the data will be stored in the database.

I have the following code and placed it in the 'Custom Element (HTML/PHP)'.

<html lang="en">
<head>
	<meta charset="utf-8" />
	<title></title>
	<link rel="stylesheet" href="styles.css" />
	<!--[if lt IE 9]>
	<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
	<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
</head>
<body>

	<div id="canvas"></div>
	<br />
	<form name="form1" method="post" action="">
	<label for="latitude"><b>Latitude:</b></label>
	<input readonly="readonly"id="latitude" type="text" value="" />
	<label for="longitude"><b>Longitude:</b></label>
	<input readonly="readonly" id="longitude" type="text" value="" />
<br />
<label><b>Omschrijving:</b></label><br />
<TEXTAREA NAME="description" id="description" COLS=40 ROWS=6></TEXTAREA>
<br />
<input type="submit" name="Submit" value="Submit">

	<script type="text/javascript" src="gmap.js"></script>
</form>
</body>
</html>


In the 'Events' tab I have in the 'On Load' the 'Show HTML'. In the 'On Submit' I have placed the 'DB Save'. In there I selected the table where it has to sore all the data.

After submitting the form I took a look at my database and I noticed that the coordinates are not saved to the database. The rest of the data (a small description that people can write) is saved to the database.



Can someone help me with this?

Regards,
Ruud
GreyHead 28 May, 2013
Hi Ruud,

The latitude and longitude inputs have no name attributes, that may be the problem.

Bob
flyboeing 28 May, 2013
Thank you Bob! I didn't notice that, some small beginners error😶.

I place my form into an article with the Chronoforms module. But the problem is that it will sent the form but won't save the data to the database! While testing the form this was working😟

Any ideas?
GreyHead 30 May, 2013
Hi Ruud,

What is the action URL of the form? There can be problems if this gets replaced with an SEF URL.

Bob
flyboeing 04 Jun, 2013
Hi Bob,

I didn't use any SEF URL. In the custom code I have no action:
<form name="form1" method="post" action="">


Regards,
Ruud
GreyHead 04 Jun, 2013
Hi Ruud,

??? If there is no action then the form will not submit anywhere useful???

Bob
flyboeing 05 Jun, 2013
Hi Bob,

That is the part I don't get. When I place the action part in my Custom HTML, the submit button ain't working. When there is no action in the Custom HTML, the form is sending (I get the 'Show Thanks Message'), but the data ain't stored in the database.

Regards,
Ruud
GreyHead 05 Jun, 2013
Hi Ruud,

You've lost me :-(

Why do you have custom form tags there? You have to turn off the ChronoForms form tags if you use custom form tags (nested <form> tags aren't allowed).

If you don't submit to ChronoForms then ChronoForms can't save the form data or send emails (or do anything as it never sees the submission).

Bob
flyboeing 13 Jun, 2013
Hi Bob,

Sorry for the late reply.

I am trying to make a form with Google Maps. There is a small map, and 4 input fields (2 of them are with the latitude and longitude and 2 others are to enter the name of the location (for example "My home") and to type a small description).

I made this entire form in HTML and put it in a Custom HTML box (in ChronoForms).

I thought this was the right way to do it, I am also a bit lost on how the make this thing work😟

Regards,
Ruud
GreyHead 14 Jun, 2013
Hi Ruud,

This will work OK - but you can't use two sets of <form> tags; you have to use either the ChronoForms tags or add your own; if you add your own then they must have an action URL set.

Bob
flyboeing 19 Jun, 2013
Hi Bob,

Thanks.
I will keep trying :wink:

Regards,
Ruud
This topic is locked and no more replies can be posted.