Click to See Complete Forum and Search --> : Pic of the week script... anyone???
ctrl-t
09-24-2003, 03:22 PM
Can anyone help me finding the following script?
I've been looking for it for quite some time now...
PICTURE BY WEEK SCRIPT!!!
Who can help?????
David Harrison
09-24-2003, 04:12 PM
How's this, it outputs the number of the current week in a variable called weeknumber and then you can use document.write to include the source code for the image.
It calculates the weeknumber based on the day of the week you consider to be the first. If you would prefer I could modify it to start from the actual first day of the year (ie: 1/1/2003).
You should realise that in some years you may need to have 53 pictures, even though there are not 53 complete weeks in the year. The script calculates from the beginning of the week and so doesn't realise that it may already be 2004, however like I said I could change this.
Anyway see what you think:
ctrl-t
09-26-2003, 04:40 AM
Thankx Lavalamp,
I see you have been putting quite some time in it.
I don't understand the script, but I'm going to test it today...
I'm a complete nitwit at Javascript, but if I understand you correct I have to have 53 pictures. Is that right?
document.write('<img src="image'+weekcount+'.gif" width="100" height="100" alt="'+weekcount+'">');
I guess by looking at the script I have to name them:
image01.gif
image02.gif
image03.gif
\\
image52.gif
image53.gif
Please let me know!!!
ctrl-t
09-26-2003, 05:12 AM
Lavalamp...
I've been testing the script, and it has 2 minor errors.
1) The weeknumber is 2 weeks off.
It says the weeknumber is 37 in stead of 39.
2) When loading the image it give this message:
See attachment!
Can those errors be resolved somehow?
ctrl-t
09-26-2003, 05:27 AM
Dear Lavalamp...
1) The weeknumber is 2 weeks off.
It says the weeknumber is 37 in stead of 39.
I figured I remove the alt: weeknumber >> some text!!!
1) When loading the image it give this message:
See attachment!
I removed the alert line!!!
Now it is working like I want it to!
David Harrison
09-26-2003, 08:49 AM
It's a little strange that the script is 2 weeks out, it shouldn't be, but I'll go over it and see if I can spot why. The alert was only to show you what code would be written for the image.
If I understand you correctly you said that taking the alert out made the script calculate the correct number of weeks, if so then I'm completely baffled because no additional calculations occur between the alert() and the document.write();.
I'll search for the error and if I find anything I'll let you know.
If you want me to explain how the script works let me know and I'll go through it for you.
David Harrison
09-26-2003, 11:25 AM
I have been through the script and found that it was only 1 week out, it was an easy fix. You have to remember that not every year will need 53 pictures, this year for instance only needs 52 pictures.
I think that I forgot to mention it in my other post, but yes you were right about having the sources for your images as "image38.gif" however you can change this. For example i could include a bit of script that would turn all number less than 10 into the format 06 rather than just 6.
You would need to systematically name all of your images using this method, so if you would prefer not to then I could create an array in which you could put the sources of all the images (from any directory), and the weeknumber would just be used to reference each image in the array.
ctrl-t
09-26-2003, 03:09 PM
Originally posted by lavalamp
I have been through the script and found that it was only 1 week out, it was an easy fix. You have to remember that not every year will need 53 pictures, this year for instance only needs 52 pictures.
I think that I forgot to mention it in my other post, but yes you were right about having the sources for your images as "image38.gif" however you can change this. For example i could include a bit of script that would turn all number less than 10 into the format 06 rather than just 6.
You would need to systematically name all of your images using this method, so if you would prefer not to then I could create an array in which you could put the sources of all the images (from any directory), and the weeknumber would just be used to reference each image in the array.
I really love the script so far!!!! :D
I now have image01.jpg to image53.jpg....
Could ya adjust the script to the 01, 02, 03 count in stead of 1, 2, 3?????
Else, the script is perfect!!!!!!!!!!!!!!!!!!!!!!!!
Many thanx for all the time you put into it!
I wonder is this script would still work if I change the .gif to .html if I would wanna load 53 different .html-files??????
Greetz....
David Harrison
09-26-2003, 03:25 PM
Like this:
ctrl-t
09-26-2003, 04:33 PM
Originally posted by lavalamp
Like this:
Dear Lavalamp...
I tested the script and I just have to say one thing about it:
IT'S PERFECT!!!
(Wish I knew something more about JS and other scripts!
But time is not my frined... Guess I'm doomed to do Graphics Designing only! I start this DTP course next week!)
Need some grapics for your site, Lavalamp.... Just let me know. Maybe I'll have some spare time!!!
Many many many THANX !!!!!!!!! ;)
David Harrison
09-26-2003, 04:59 PM
I kind of feel the same way as you. I know JavaScript, XHTML and CSS but I'm trying to break into the world of ASP and finding it slow going. ASP uses a language called VBScript and it's supposed to be simple but I don't see it that way.
Anyway, I'm just happy to help. :)
ctrl-t
09-26-2003, 05:52 PM
Originally posted by lavalamp
I kind of feel the same way as you. I know JavaScript, XHTML and CSS but I'm trying to break into the world of ASP and finding it slow going. ASP uses a language called VBScript and it's supposed to be simple but I don't see it that way.
Anyway, I'm just happy to help. :)
My problem now is that I got this great ideas for some dynamic pages, but my scripting sucks....
I also have to disappoint some possible clients who want a dynamic website....
Always my standard line: "Sorry, but my expertise is only graphic. I can't provide you that dynamic site!"
I haven't found someone yet who has the knowledge or sparetime to help me with that (for allmost no cost).
I hate turning down good costumers.... but hey..
Life sucks anyway you slice it!
Maybe the future brings some sunshine!
David Harrison
09-26-2003, 06:02 PM
There may be a couple of good web-sites for you to take a look at, they just hand out free code:
HTML Goodies (http://www.htmlgoodies.com/)
Dynamic Drive (http://www.dynamicdrive.com/)
Also if you are interested in learning there is always W3Schools (http://www.w3schools.com/).
I'm hoping to launch a tutorials site of my own some way off in the future as well, with tutorial/example scripts for (X)HTML, CSS, JavaScript & DHTML, but I don't think it will be up any time before Christmas.
Until then there's always those other web-sites, this forum and another set of forums that I'm part of, Coding Forums (http://www.codingforums.com/).
I'd love to be able to help you out whenever possible, however this little thing called school seems to get in the way of everything.