| View previous topic :: View next topic |
| Author |
Message |
Iain
Joined: 30 Nov 2006 Posts: 2
|
Posted: Fri Dec 01, 2006 10:49 am Post subject: Here's a 5 second question for all you experts |
|
|
It's my first day trying javascript... and I cannot understand why I cannot load an image subject to an "IF" condition....
What is wrong with this?
<script type="text/javascript">
if ...... //I'm ok with the condition//
{
img src="gifs/xxred.gif"
}
else
{
img src="gifs/xxgreen.gif"
}
</script>
All I wan't to do is make a gif appear based on a condition....
Can anyone help me with what I'm sure is the simplest of problems..! |
|
| Back to top |
|
 |
|
|
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
Posted: Fri Dec 01, 2006 6:05 pm Post subject: Re: Here's a 5 second question for all you experts |
|
|
I'm no expert at Javascript, but I beleive if you want to show something conditionally you need to have:
document.write("<img src='gifs/xxred.gif'>");
instead of just img src="gifs/xxred.gif";
Hope this helps
-Mike |
|
| Back to top |
|
 |
ngpgeeta
Joined: 18 Nov 2006 Posts: 19
|
Posted: Sun Dec 17, 2006 11:42 am Post subject: Re: Here's a 5 second question for all you experts |
|
|
<html><head>
<script>
function change()
{
if(condition)
{
document.first.src="gifs/xxred.gif"
}
else
document.first.src="gifs/xxgreen.gif"
}
</script></head><body>
<img name="first" src="xx.gif"></body></html>
Now where you have to call function change(), you have to decide.Hope this helps! |
|
| Back to top |
|
 |
|