Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Here's a 5 second question for all you experts



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
Iain



Joined: 30 Nov 2006
Posts: 2

PostPosted: Fri Dec 01, 2006 10:49 am    Post subject: Here's a 5 second question for all you experts Reply with quote

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
View user's profile Send private message
mwa103
100+ Club


Joined: 07 Mar 2005
Posts: 206

PostPosted: Fri Dec 01, 2006 6:05 pm    Post subject: Re: Here's a 5 second question for all you experts Reply with quote

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
View user's profile Send private message MSN Messenger
ngpgeeta



Joined: 18 Nov 2006
Posts: 19

PostPosted: Sun Dec 17, 2006 11:42 am    Post subject: Re: Here's a 5 second question for all you experts Reply with quote

<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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap