I'm working with a wordpress theme, in the admin control panel I' ve added settings for the theme, here I can write some variables, like longitude and latitude for a map (works), and an email, that I need for a contact form, but this doesn' t work, I suppose that the problem is that I use
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/contact-form/contactform.js"></script>
In fact if I do the same with the map, that now is
<div id="gmapp"></div>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var lat;
var lng;
lat=<?php echo($GLOBALS['desklab_theme_settings']['latcord_text']);?>;
lng=<?php echo($GLOBALS['desklab_theme_settings']['lngcord_text']);?>;
var latlng = new google.maps.LatLng(lat,lng);
var options = {
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('gmapp'), options);
var marker = new google.maps.Marker(
{
position: latlng,
map: map
}
);
</script>
I tried to write so:
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/contact-form/map.js"></script>
But I don't see the map, and variables aren't found.
So what should I do to get the variable from settings as I do with lat and lng? I should write the js code in the php as I did with map?