Jump to content

Recommended Posts

Hi

 

I have the code below which geocodes a postcode and returns a lat a long value. Its standard code from Google maps. I just want to print these values to a screen.  I tried document.write(value) but this produces nothing.  Any help would be greatly appreciated.

 

<script type="text/javascript">
var localSearch = new GlocalSearch();
function usePointFromPostcode(postcode)
{
	localSearch.setSearchCompleteCallback(null, 
		function()
		{
			if (localSearch.results[0])
			{		
				var resultLat = localSearch.results[0].lat;
				var resultLng = localSearch.results[0].lng;
			}


			document.write(resultLat+resultLng); 


			//alert("Latitude: " + resultLat + "\nLongitude: " + resultLng + " q");				
		});	
	localSearch.execute(postcode + ", UK");
}
</script>

 

TIA Stew

Link to comment
https://forums.phpfreaks.com/topic/174165-help-with-printing-to-screen/
Share on other sites

I posted a link showing how to use innerHTML. I'm not exactly sure why the document.write() method isn't working.. I can't remember the last time I used it to be fair, so I don't know a great deal about it. From the sounds of it though browsers have trouble with it when it's used within XHTML pages, take a look here. I'd say forget about document.write() and learn how to use other methods, namely innerHTML.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.