Click to See Complete Forum and Search --> : Trying to use images as responses to an if statment


katie
06-26-2003, 05:01 PM
I am just getting into Java Script because I have to...lol, and am totally lost..
We are trying to use an if statement (function??) tied to the time of day...and want the response to be a different greeting for each different condition and also have a different image tied to the greeting.

The responses are not a problem... but I do not know how to code the images so they will tie to the responses... (only know enough html to get myself in trouble..but do know the basic tags and img src tags).


Here is the code with out the images..

________________________________________________

<script language="JavaScript">
<!-- hide script from old browsers
// Modified by CoffeeCup Software
function process(){}

today = new Date()

if(today.getMinutes() < 10) {
pad = "0"}
else
pad = "";
document.write("<center><FONT SIZE=4 color=yellow></FONT></center>")

if((today.getHours() < 12) && (today.getHours() >= 6))
{ document.write("<center><FONT SIZE=4 color=blue>Good Morning</FONT></center>")}

if((today.getHours() >= 12) && (today.getHours() < 18))
{ document.write("<center><FONT SIZE=4 color=red>Good Afternoon</FONT></center>")}

if((today.getHours() >= 18) && (today.getHours() <= 23))
{ document.write("<center><FONT SIZE=4 color=white>Good Evening</FONT></center>")}

if((today.getHours() >= 0) && (today.getHours() < 4))
{ document.write("<center><FONT SIZE=4 color=purple>You're up late today.</FONT></center>")}

if((today.getHours() >= 4) && (today.getHours() <= 6))
{ document.write("<center><FONT SIZE=4 color=yellow>Wow! You are up early!!</FONT></center>")}

document.write("<center><FONT SIZE=3 color=blue>Time: ",today.getHours(),":",pad,today.getMinutes())

document.write(" Date: ",today.getMonth()+1,"/",today.getDate(),"/",today.getYear(),"<br></font></center>");
// end hiding contents -->
</script>

______________________________


Any help would be appreciated ... our images are on a website and have the normal addresses for the urls.... so we just need to know how to write it so it will appear with the different greetings...

Thanks in advance for any help...
Having a blast learning and reading up in manuals... but can't seem to find an answer for this that we can understand.

THanks a bunch,
Katie

Khalid Ali
06-27-2003, 12:38 AM
Though I am not a big fan of document.write...you adding an image to this is fairly simple

change this line
document.write("<center><FONT SIZE=4 color=blue>Good Morning</FONT></center>")

to this

document.write("<center><FONT SIZE=4 color=blue>Good Morning</FONT><br<img src='someImage.gif'/></center>")

katie
06-28-2003, 05:53 AM
;) :D

Thank you very much, I shall try it this weekend and let you know how it works!
Katie