Image through Script, How to add variable to URL
- by Liso22
I'm sure it's pretty straightforward since someone just solved a similar problem I had. I have a folder full of city images and need users to see the image corresponding to their city.
Right now I'm getting the users location without problem using "geoip_city()" but I don't quite know how to integrate it into the URL of the image. All images have the following format: New York.jpg, Boston.jpg so I just need to make the script put the location before .jpg
This is what I'm trying now:
<img src="blank.png" id="image" >
<script type="text/javascript">
document.getElementById('image').src = "Imagenes/grupos/' + geoip_city() + '.jpg";
</script>
I believe I'm just messing with the quotes or something similar. Could anyone tell me what I'm doing wrong? Also this is where I'm testing it: http://chusmix.com/?page_id=1770
Thanks