1.

Solve : Change Image on a certain Day?

Answer»

How would I code a change to an image in html? I imageing that I would have to have it coded in javascript. But I hate to try an code it in java myself.This will help you, I'm not sure how to do the whole thing.
Code: [Select]<script type="text/javascript">
var date=new Date();
document.write(""+ date +"");
if (date==12/13/2008)
{
document.write("this will help you");
}
</script>
that should help out a little but are you haveing this should help appear as a message?

??

isnt that the full code?Found this php routine which changes image for each day - might be something to start with and modify.

Code: [Select]<html>
<head>
<title>Today is <?phpechodate("l");?></title>
</head>
<body>
<?php
/*ThisPHPScriptdevelopedbyScottClark
TheSourceisavailableathttp://www.clarksco.com/dev/
Copyright2005ClarkConsulting*/
//Variables
$url="http://YOURDOMAIN.COM/images/";
$monImage="$url"."monday.jpg";
$tueImage="$url"."tuesday.jpg";
$wedImage="$url"."wednesday.jpg";
$thurImage="$url"."thursday.jpg";
$friImage="$url"."friday.jpg";
$weekendImage="$url"."weekend.jpg";
$d=date("D");
//Functionthatswitchesbetweendateimagesbasedontheactualdayoftheweekin$d
switch($d)
{
caseMon:
ECHO"<imgsrc=$monImage>\n";
break;
caseTue:
echo"<imgsrc=$tueImage>\n";
break;
caseWed:
echo"<imgsrc=$wedImage>\n";
break;
caseThu:
echo"<imgsrc=$thurImage>\n";
break;
caseFri:
echo"<imgsrc=$friImage>\n";
break;
default:
echo"<imgsrc=$weekendImage>\n";
}
//End
?>
</body>
</html>
I dont understand your code. jacob yours dont work.Quote from: squall_01 on October 03, 2008, 10:04:20 AM

I dont understand your code.

You mightn't understand it, but it should work.Quote from: squall_01 on September 21, 2008, 06:59:37 AM
How would I code a change to an image in html?

People, SQUALLY wants it in CLIENT SIDE script, PHP is server side. I doubt that he's running a server.

now, with that out of the way- he also wants to change an image.

Now, this can't be done in HTML, but it can be done in Javascript.

I don't have a good recollection, so anything I write here wouldn't work. Instead I think you could search dynamicdrive.com, they have some great scripts you can use in ADDITION to what your looking for, I'm sure.

Just one last thing however.

Quote from: squall_01 on September 21, 2008, 06:59:37 AM
.... I would have to have it coded in javascript. But I hate to try an code it in java myself.


Java and JavaScript are two DIFFERENT languages completely. Java is a compiled language DEVELOPED by Sun Microsystems. JavaScript was developed by netscape as "LiveScript" but they changed the name when they saw Java gaining fame.
thats what I am saing. it would be a complete pain. yeah they should have something like that if I recall.any one taht run javascript instead of like php.Try this...

Code: [Select]<script type="text/javascript">

var d=new Date();
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";

if(weekday[d.getDay()]==0)
{
document.write("<img src='image1.gif' />");
}

elseif(weekday[d.getDay()]==1)
{
document.write("<img src='image2.gif' />");
}

elseif(weekday[d.getDay()]==2)
{
document.write("<img src='image3.gif' />");
}

elseif(weekday[d.getDay()]==3)
{
document.write("<img src='image4.gif' />");
}

elseif(weekday[d.getDay()]==4)
{
document.write("<img src='image5.gif' />");
}

elseif(weekday[d.getDay()]==5)
{
document.write("<img src='image6.gif' />");
}

elseif(weekday[d.getDay()]==6)
{
document.write("<img src='image5.gif' />");
}

else
{
document.write("Can't tell what day it is!");
}
;

</script>


Discussion

No Comment Found