Click to See Complete Forum and Search --> : image


Ritz
02-24-2003, 08:09 AM
I have a very simple problem, but I have spent over three days to find the solution, but unsuccesfully.

I have a variable a.
If a=1 while loading the page I want a text and an image to show on my web page.
If a=0 while loading the page I want the text and image to remain hidden.


With text I do it like this:
______________________________________________
<SCRIPT LANGUAGE="JavaScript">
if (a==1) document.write("This is the text");
</SCRIPT>
______________________________________________


However i seem not to be able to include an image in the
write() function. Nor can I use the 'if'-statement in HTML.
How can I solve this?

I hope you can help me.

Nicodemas
02-24-2003, 08:52 AM
put this whereever you want the text and image to appear, making substitutions for the file paths and names where appropriate:

You made a slight mistake with the syntax of your if statement in your above sample, as you forgot to use the curly brackets after the conditional statement


<SCRIPT>
if (a==1) {document.write("some text.... <IMG SRC='filepath_to_images'>")}
</SCRIPT>