0

i'm trying to echo a variable to a search box to be the placeholder and the value the search box will search on google maps.

the variable is $address

$address = $_SESSION['mylocation']['address'];

and then in html i've this form

<input name="custom[map_location]" id="form_map_location" class="controls" type="text" placeholder="<?php echo $address ?>" value="<?php  echo $address ?>">

the variable echos fine, but to really choose the value echoed and change the location to the echod value i've to click inside the text form box and then click away, then it detects the location, i need to do this automatically without clicking inside the form

i've added a chunk of the code that loads the map http://pastebin.com/XMZiXwiW

Ahmed Nabil
  • 53
  • 1
  • 9

1 Answers1

0

Are you passing the variable in the input to the JavaScript function via the on change event?

If you are you may need to create two listeners 1. "Change event" to capture new values that get put in the input field 2. "Document Ready event" to grab the value you are passing via PHP and use it when building the map.

Not sure if this is how you are going about things but hopefully it helps. If I am off base here, can you share more of your work so I can see how your initiating the map and updating it.

  • i don't know what you really need, but here is a big snippet of the php file that loads the map http://pastebin.com/XMZiXwiW – Ahmed Nabil Jun 10 '16 at 23:24
  • Jim - this is your first answer so, i guess, you're not very familiar with the markdown syntax. It is worth learning to make more appealing answers. Also, do not be afraid of making very long answers. For example, if you could give an example snippet of both listeners you're mentioning your answer would be much better. – grochmal Jun 10 '16 at 23:38
  • Looking at how much there is going on I would start out with the basics and add back a piece at a time. Make sure that the variables you need are being captured properly and then go from there. I simplified your page down to the bare minimum so that I could ensure I was getting the value of the #form_map_location element. – Jim Johnson Jun 11 '16 at 03:59
  • Start here and then work forward, testing with each piece. – Jim Johnson Jun 11 '16 at 04:00
  • Had to split up my answer into a few comments. First time posting to this, I have received a lot of help from the users on Stack Overflow so just trying to return the favor. Hopefully you get things resolved. – Jim Johnson Jun 11 '16 at 04:05