Current location: Hot Scripts Forums » General Web Coding » JavaScript » How to display images for each day in total year


How to display images for each day in total year

Reply
  #1 (permalink)  
Old 06-14-05, 01:23 PM
ajay007_bond ajay007_bond is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
How to display images for each day in total year

I am working on a weather webpage....I want to display a daily updated image for 365 days in a year....I have 365 images in my server......so I want to display a daily image like image for January 1st, image for Jan 2nd image..like that untill December 31st.....

Can any one provide the java script
Reply With Quote
  #2 (permalink)  
Old 06-16-05, 07:03 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
How are your files named and placed? One folder for each month? Examples please...

This should be no hard to do if you already have the images.
You'll simply have to generate an src-attribute that matches the current date and the wanted file.
Reply With Quote
  #3 (permalink)  
Old 06-18-05, 05:04 AM
sarat.pediredla sarat.pediredla is offline
Newbie Coder
 
Join Date: Jun 2005
Location: Newcastle upon Tyne UK
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Here it goes

TwoD's question is valid but the solution would be something in the lines of,

Assume your files are named in the format dd_mm.jpg where dd is the day and mm is the month for which it needs to be displayed.

1. Place the following code in your <head></head> section
Code:
<script language="javascript">
function loadImage()
{
	var today = new Date();
	var imgString = today.getDate()+"_"+today.getMonth()+".jpg";
	document.getElementById("weatherimg").src = imgString;
}
</script>
2. And modify your <body> tag as follows
Code:
<body onLoad="loadImage();">
Replace weatherimg (keep double quotes) with the id of the img tag where you want the image to be displayed.

If you have no control over the filenames, then it is a little different since you might need to create an array of these files into your code (easiest hack and doesnt take too long for 365 image names).

If you can't figure it out even now, then just IM me and I will integrate it for you.
__________________

--------------------------------
Sarat Pediredla
[Writing a lot about nothing]
Blog : Space & Beyond


<a href="http://www.spreadfirefox.com/?q=affiliates&amp;id=108865&amp;t=68"><img border="0" alt="Get Firefox!" title="Get Firefox!" src="http://sfx-images.mozilla.org/affiliates/Buttons/88x31/take.gif"/></a>

Last edited by sarat.pediredla; 06-18-05 at 05:07 AM. Reason: Error in code
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
display text depending on day ancdy PHP 4 05-24-05 03:28 AM
Mac does not display images Jebediah JavaScript 3 03-22-05 01:25 PM
display images in a datagrid or table from mysql database. bin ASP 1 01-03-05 06:34 PM
images dont display, not wrong path eq1987 HTML/XHTML/XML 2 11-29-04 03:42 AM
is it a good idea to run 23 search expressions? lordmerlin ASP 1 03-24-04 04:05 PM


All times are GMT -5. The time now is 10:48 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.