Link to home
Start Free TrialLog in
Avatar of bryskyd
bryskyd

asked on

Photo of The Day Script for use in a .html file from a Database?

I'm looking to find something that can be used on an html page, either by virtual include or in-page code that could refrence a photo of the day either by date alon - photos named like such: "02_1120.jpg" or from a database that could have 365 Entries, one for each day of the year, where I could enter the file names, and have them swapped out for a variable called on the page.

Please help!

Thanks,
Bryskyd
Avatar of gtamir
gtamir

Just copy & paste from that line:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--

function getPicName(){
     var dt;
     var mm;
     dt = new Date()
     mm =dt.getMonth() + 1;
     //rslt = dt.getFullYear().toString();
     alert(dt.getFullYear().toString() + '_' + mm.toString() + dt.getDate().toString() + '.jpg');
}
//-->
</SCRIPT>

</HEAD>
<BODY>

<P>&nbsp;</P>
<input type="button" value="Click me" onclick="javascript:getPicName();")>

</BODY>
</HTML>



HTH,
Gal.
<html>
<head>
<title> date pic</title>
<script language="JavaScript>
<!--
function setImage()
{
   var thedate=new Date();
   var mon=thedate.getMonth;
   mon++;
   var str=thedate.getYear()+"_"+mon+thedate.getDate()+".jpg";
   document.images['theimg'].src=str;
}
onload=setImage;
//-->
</script>
</head>
<body>
<img src="" name="theimg">
</body>
</html>
Avatar of bryskyd

ASKER

This looks good, but COBOLdinosaur, where would i add the /dir/dir/images.jpg if the images are not in the same folder?
The path goes right at the start of the string:

var str="dir/dir/"+thedate.getYear()+"_"+mon+thedate.getDate()+".jpg";


Cd&
Avatar of bryskyd

ASKER

This looks good, but COBOLdinosaur, where would i add the /dir/dir/images.jpg if the images are not in the same folder?
In what folder are they ?
Avatar of bryskyd

ASKER

COBOLdinosaur, it doesn't seem to be working, here's the page where I'm trying to use it:

http://www.bexperiment.com/potd_new.html

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bryskyd

ASKER

Interesting, now it pulls the following image:

http://www.bexperiment.com/_gfx/potd/2002_NaN21.jpg

Instead of the correct:
http://www.bexperiment.com/_gfx/potd/02_1121.jpg

If I need to rename all of the images to use 2002 I will, however the month and day still do not pull correctly.

Any Ideas?
Avatar of bryskyd

ASKER

Nevermind.. sometimes I get so dense. I didnt read your previous message all the way through. I only corrected the "javascript" not get month.

Thanks!

<Question Solved!>
Avatar of bryskyd

ASKER

Followed up, EXCLENT!
Glad I could finally get it right.  Thanks for the A. :^)

Cd&
Avatar of bryskyd

ASKER

No problem.. looks like your the top dog around here!

One last question: do you have any idea why it breifly shows a "image not found" red X before it loads the image? (http://www.bexperiment.com/potd.html)

Now I got to post a follow up question to see how I can get a Drop Down menu with all of the previous Photos of the Day.

Soon those links on the left hand side just wont cut it! :)
Avatar of bryskyd

ASKER

Oh no, I'm out of points.. how does a newbie get more points around here? :)
The red x is because the browser it putting a placeholder for the image.  It does not generate teh name of the source until after the page is loaded.  You can get around it by creating a small transparent image and name it blank.gif then change the tag like this:
<img src="blank.gif" name="theimg">
now it will load in the blank gif during the initial rendering and the the script will replace the source of the image.

For the drop down menu, you might find what you need here:
www.dynamicdrive.com
They have quite a few pre-written scripts and most of them are easy to customize.

As for points:
https://www.experts-exchange.com/Web/Web_Languages/HTML/memberEarnPoints.jsp

Cd&