Foren / Craftwork / Client-side / [solved] Construct img tag with javascript and php

JonnyM
#12412 13. Mai 2009, 03:19
Hi,

I'm trying to construct a dynamic img tag by doing the following:

1. Call a PHP file like so:
<script type="text/javascript" src="http://localhost/myfile.php?id=1"></script>

2. This PHP file makes some SQL calls and then echoes out:
echo "document.write(\"<img src=\"http://www.huddletogether.com/projects/lightbox2/images/image-2.jpg\">\")";

Now this works for echoing out text like "Hello" or whatever, but any image won't show.
So my question is, how should I go about do this ?

ps. This can NOT be solved by preconstructing the img tag, since the output of the PHP file might just as well be a movie or flash or whatever.

I have looked all over the net and this is how far I have gotten. Since I don't know Javascript / AJAX at all, I'm stuck for now.

Thx in advance for any help !

Dieser Beitrag wurde von JonnyM (am 14. Mai 2009, 01:46, vor 16 Jahre) bearbeitet