Populate Text Box With Map Marker Click

830 views
Skip to first unread message

IR HM

unread,
Nov 17, 2011, 10:24:58 AM11/17/11
to Google Maps JavaScript API v3
I wonder whether someone can help me please with a problem I've been trying to sort out most of the week.
 
I have the following page here that allows the user to view certain map markers upon selection and deselection of check boxes.
 
What I'm now trying to do is to populate a text field called 'address' with the address details when the markers on the map are clicked. I know that I pulling the data from the php script, but for the life of me I can't find a way of populating the text box with the information.
 
I'm using the following code in line 49 of my script: document.getElementById('address').value = address; but upon clicking the marker all I receive is a'undefined' in the 'address' text field. I've tried adding this to various points within the code without any success.
 
Could someone perhaps please show me what i need to change to get this to work.
 
Many thanks and kind regards.

Marcelo

unread,
Nov 17, 2011, 11:55:04 AM11/17/11
to Google Maps JavaScript API v3
Try replacing:

document.getElementById('address').value = address;

with:

document.getElementById('address').value = this.myname;

--
Marcelo - http://maps.forum.nu
--



On Nov 17, 8:24 am, IR HM <hobbito...@googlemail.com> wrote:
> I wonder whether someone can help me please with a problem I've been trying
> to sort out most of the week.
>
> I have the following page
> here<http://www.mapmyfinds.co.uk/development/mylocationstest.html>

IR HM

unread,
Nov 17, 2011, 12:14:25 PM11/17/11
to google-map...@googlegroups.com
Hi, many thanks for this, I actually changed it to 'myaddress' as this is the actual address field containing the data.
 
However I've still got the same problem in that the text field shows the value as 'undefined'. I've checked the php script that pulls the data from the database and the data is being pulled through correctly, so I'm not sure what I'm doing wrong.
 
kind regards

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


IR HM

unread,
Nov 17, 2011, 1:23:36 PM11/17/11
to google-map...@googlegroups.com
Hi, I've managed to get this to work. 
 
I had left out the declaration of the address with the other pieces of information that made up the marker information.
 
many thanks for your help.
 
Kind regards

Reply all
Reply to author
Forward
0 new messages