PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Ghoz
Forum Commoner
Posts: 38 Joined: Thu Jul 12, 2012 2:32 am
Post
by Ghoz » Tue Nov 06, 2012 7:38 am
Hi,
This code will call the js
Code: Select all
<script src="http://export.giveawayoftheday.com/index.js"></script>
This code will output the url of the image
Code: Select all
<script type="text/javascript">document.write(gaotdObj.screenshot)</script>
How to echo the url to display the image in <img src=""> ???
Thanks!
Tiancris
Forum Commoner
Posts: 39 Joined: Sun Jan 08, 2012 9:54 pm
Location: Mar del Plata, Argentina
Post
by Tiancris » Tue Nov 06, 2012 9:23 am
This should do the trick:
Code: Select all
<img id="theImage" src="">
<script>
document.getElementById("theImage").src = gaotdObj.screenshot;
</script>
Probably you have to use this code within an event like window.onLoad, or <body onload="">, that depends of how your app works.
Ghoz
Forum Commoner
Posts: 38 Joined: Thu Jul 12, 2012 2:32 am
Post
by Ghoz » Tue Nov 06, 2012 7:49 pm
Thanks, it works!
Anyway both of these codes are working, but which one should I use??
Code: Select all
echo 'document.getElementById("theImage").src = gaotdObj.screenshot';
Code: Select all
echo 'document.getElementById("theImage").src = gaotdObj.screenshot;';
Tiancris
Forum Commoner
Posts: 39 Joined: Sun Jan 08, 2012 9:54 pm
Location: Mar del Plata, Argentina
Post
by Tiancris » Wed Nov 07, 2012 1:25 pm
I always write ";" at the end of each line
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Fri Nov 09, 2012 12:12 am
Ghoz wrote: but which one should I use??
you should go for the option with the semi-colon at the end. a semi-colon indicates the end of a statement in javascript (as in other programming languages)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering