473,748 Members | 10,889 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change image depending on date

Hello all,

I have the script below to change an image depending on the date upto
january it worked fine but then it just stopped working does anybody have an
idea how I can make it work again or why it doesn't work?

Thanks in advance

Tjerk
<SCRIPT LANGUAGE="JavaS cript1.1">
<!-- Beginning of JavaScript -
today=new Date(); //determines the current date
start=new Date("October 8, 2003"); //date you want your image to start
displaying
end=new Date("November 7, 2003"); //date you want your image to stop
displaying
start1=new Date("November 7, 2003"); //date you want your image to start
displaying
end1=new Date("December 6, 2003"); //date you want your image to stop
displaying
start2=new Date("December 6, 2003"); //date you want your image to start
displaying
end2=new Date("December 20, 2003"); //date you want your image to stop
displaying
start3=new Date("December 20, 2003"); //date you want your image to start
displaying
end3=new Date("January 18, 2004"); //date you want your image to stop
displaying
start4=new Date("January 18, 2004"); //date you want your image to start
displaying
end4=new Date("Febuary 4, 2003"); //date you want your image to stop
displaying
start5=new Date("Febuary 4, 2003"); //date you want your image to start
displaying
end5=new Date("Febuary 14, 2004"); //date you want your image to stop
displaying
start6=new Date("Febuary 25, 2004"); //date you want your image to start
displaying
end6=new Date("March 18, 2004"); //date you want your image to stop
displaying
start7=new Date("March 18, 2004"); //date you want your image to start
displaying
end7=new Date("April 11, 2004"); //date you want your image to stop
displaying
start8=new Date("April 11, 2004"); //date you want your image to start
displaying
end8=new Date("April 22, 2004"); //date you want your image to stop
displaying
start9=new Date("April 22, 2004"); //date you want your image to start
displaying
end9=new Date("May 5, 2004"); //date you want your image to stop displaying
start10=new Date("May 5, 2004"); //date you want your image to start
displaying
end10=new Date("June 4, 2004"); //date you want your image to stop
displaying
start11=new Date("June 4, 2004"); //date you want your image to start
displaying
end11=new Date("June 11, 2004"); //date you want your image to stop
displaying

/*if the current date is between the start and end dates that you set,
then your special image is displayed. Otherwise your default image is
displayed. Be sure to include width and height tags for NN2*/

if ((today.getTime ()>=start.getTi me()) &&
(today.getTime( )<=end.getTime( ))){
document.write( "<IMG SRC='Images/waar/india.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start1.getT ime()) &&
(today.getTime( )<=end1.getTime ())){
document.write( "<IMG SRC='Images/waar/thailand.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start2.getT ime()) &&
(today.getTime( )<=end2.getTime ())){
document.write( "<IMG SRC='Images/waar/laos.gif' WIDTH='137' HEIGHT='103'>") ;
}
if ((today.getTime ()>=start3.getT ime()) &&
(today.getTime( )<=end3.getTime ())){
document.write( "<IMG SRC='Images/waar/vietnam.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start4.getT ime()) &&
(today.getTime( )<=end4.getTime ())){
document.write( "<IMG SRC='Images/waar/cambodja.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start5.getT ime()) &&
(today.getTime( )<=end5.getTime ())){
document.write( "<IMG SRC='Images/waar/thailand.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start6.getT ime()) &&
(today.getTime( )<=end6.getTime ())){
document.write( "<IMG SRC='Images/waar/mexico.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start7.getT ime()) &&
(today.getTime( )<=end7.getTime ())){
document.write( "<IMG SRC='Images/waar/guatemala.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start8.getT ime()) &&
(today.getTime( )<=end8.getTime ())){
document.write( "<IMG SRC='Images/waar/honduras.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start9.getT ime()) &&
(today.getTime( )<=end9.getTime ())){
document.write( "<IMG SRC='Images/waar/nicaragua.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start10.get Time()) &&
(today.getTime( )<=end10.getTim e())){
document.write( "<IMG SRC='Images/waar/costarica.gif' WIDTH='137'
HEIGHT='103'>") ;
}
if ((today.getTime ()>=start11.get Time()) &&
(today.getTime( )<=end11.getTim e())){
document.write( "<IMG SRC='Images/waar/usa.gif' WIDTH='137' HEIGHT='103'>") ;
}
else{
document.write( "<IMG SRC='Images/waar/nederland.gif' WIDTH='137'
HEIGHT='103'>") ;
}
// - End of JavaScript - -->
</SCRIPT>
Jul 20 '05 #1
2 4181
Tjerk wrote on 17 feb 2004 in comp.lang.javas cript:
I have the script below to change an image depending on the date upto
january it worked fine but then it just stopped working does anybody
have an idea how I can make it work again or why it doesn't work?


Dag Tjerk

Het is niet "Febuary" maar "February"
Je zult in end4 en start5 2004 bedoelen waar 2003 staat.

de >= en de > schelen 1 miliseconde
javascript versie specificeren is niet zinvol
"<!-- Beginning of JavaScript -" ook niet erg zinvol

=============== =============== =============== ===

Ik heb de zaak nog eens wat leesbaarder opgesteld,
probeer het maar eens zo:

<SCRIPT>
var start = new Array()
var end = new Array()
var beeld = new Array()

var today=new Date()

start[0]=new Date("October 8, 2003")
end[0]=new Date("November 7, 2003")
start[1]=new Date("November 7, 2003")
end[1]=new Date("December 6, 2003")
start[2]=new Date("December 6, 2003")
end[2]=new Date("December 20, 2003")
start[3]=new Date("December 20, 2003")
end[3]=new Date("January 18, 2004")
start[4]=new Date("January 18, 2004")
end[4]=new Date("February 4, 2004")
start[5]=new Date("February 4, 2004")
end[5]=new Date("February 20, 2004")
// end[5] date changed for testing
start[6]=new Date("February 25, 2004")
end[6]=new Date("March 18, 2004")
start[7]=new Date("March 18, 2004")
end[7]=new Date("April 11, 2004")
start[8]=new Date("April 11, 2004")
end[8]=new Date("April 22, 2004")
start[9]=new Date("April 22, 2004")
end[9]=new Date("May 5, 2004")
start[10]=new Date("May 5, 2004")
end[10]=new Date("June 4, 2004")
start[11]=new Date("June 4, 2004")
end[11]=new Date("June 11, 2004")
beeld[0]='india.gif'
beeld[1]='thailand.gif'
beeld[2]='laos.gif'
beeld[3]='vietnam.gif'
beeld[4]='cambodja.gif'
beeld[5]='thailand.gif'
beeld[6]='mexico.gif'
beeld[7]='guatemala.gif '
beeld[8]='honduras.gif'
beeld[9]='nicaragua.gif '
beeld[10]='costarica.gif '
beeld[11]='usa.gif'
var b = 'nederland.gif'
for (i=0;i<=11;i++) {
if ((today.getTime () > start[i].getTime()) &&
(today.getTime( ) < end[i].getTime()) ){
b = beeld[i]
i=100
}
}

var t="<IMG SRC='Images/waar/" + b + "' WIDTH='137' HEIGHT='103'>"
document.write( t)

</SCRIPT>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
JRS: In article <c0**********@r eader10.wxs.nl> , seen in
news:comp.lang. javascript, Tjerk <in**@tjerkstra vels.com> posted at Tue,
17 Feb 2004 12:47:29 :-

I have the script below to change an image depending on the date upto
january it worked fine but then it just stopped working does anybody have an
idea how I can make it work again or why it doesn't work? ... start4=new Date("January 18, 2004");
...
end4=new Date("Febuary 14, 2004");


It will work if we ever have a month called Febuary. The present month
is called February.

Better to use new Date("2003/02/14") // less typing.
Your code is very repetitive. It could be shortened by using array
data, something like :-

var Data = [
{C:"potaniland" , S:"2004/05/06", F:"2004/06/07"},
{C:"lumbago", S: ...
... ]

for (J=0; J<Data.length;J ++) with (Data[J])
if (today>=S && today<F)
document.write( "<IMG ... waar/", C, ".gif ...")

where today is now a string YYYY/MM/DD.

In fact, you only need to store the start date; scan until you find one
<= today, then finish (use break). Put a "catch all" of 9999/99/99 at
the end, preceded by one for Nederland.

Compare <URL:http://www.merlyn.demo n.co.uk/js-date1.htm#SS>

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2924
by: Jason Murry | last post by:
I have a camera system (Axis) which stores JPG via FTP 1-10fps. There is also a motion jpg live stream. I am trying to store these images either in JPG or in video format so they can be reviewed at a later date. I would need to be able to pull a date-time range from the list. This means 86,400 - 2,160,000 images (around 110Kb a piece) per camera a day, depending on speed 1fps - 10fps. There will probably be 1-5 cameras typically. ...
9
9580
by: matthiasjanes | last post by:
Hi, Maybe someone of you can help me. I'm trying to display an image in memory(open file) with an cgi script - but it want work proberly: I'm running an Cgi webserver (CgiServerGui.py). both files are in the /cgi/ folder
3
1835
by: Miguel Dias Moura | last post by:
Hello, i know how to hide a table according to a condition: <table runat="server" visible='<%# dataSetBibliotecas.FieldValue("Titulo", Container) <> "" %>'... Now I am trying to change the image file as follows: - Show the image "yes.gif" if the value of a dynamic field is equal to "YES"; - Show the image "no.gif" if the value of a dynamic field is equal to "NO".
6
4575
by: Corobori | last post by:
I am writing a vb.net application where I need to store image in a SQL Server database, yes I know I shouldn't but my clients wants it and has his reasons to do so. In order to reduce the database size I was wondering how I could compress the image (coming from a scan made by Pegasus TwainPro). I saw some possibility in the TwainPro doc but the samples do not contain much description. I was thinking of using Xceed Streaming Compression to...
3
3312
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have chosen the smallest date/time formats. When the aspx page runs, it shows the date and time (ie:in a...
3
3190
by: vj | last post by:
how to change images based on action. Even clicking changed images should do respective actions. and while displaying only one image at a time sholud get displayed. I am using three images for a single column of a table in Jsp. Any clues. Any link for any good javascript html jsp site where i can find some good solution. here swaping hiding which will work well.
5
2969
by: Rex | last post by:
Hi, I want to change a value in one table depending on the value(s) in another table. I am trying to achieve this in a form. to elaborate I have a many-to-many relationship between tables Forms and Family and the associate table is called Forms_Family. Forms_Family have fields "dateSent" and "dateReceived". The Family table has a field called
11
26627
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package and PEAR is in c:\wamp\php\pear I modified php.ini in the c:\wamp\php directory to reflect the actual path, but even stopping and restarting my server shows the c: \php5\pear path. I can't change it no matter what I do I also tried the...
10
2776
by: mukeshrasm | last post by:
Hi the code written below is for calculating the number of days remain for a particular event based on the specific local time i.e. time in new york or time in london. <style style="text/css"> .lcdstyle{ /*Example CSS to create LCD countdown look*/ background-color:black; color:lime; font: bold 18px MS Sans Serif;
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.