Jump to content

Help with printing to screen


stewc

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.