Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

monday only please!

Original Message
Name: Stephen Allden
Date: December 13, 2007 at 12:45:09 Pacific
Subject: monday only please!
OS: Windows XP
CPU/Ram: 533Mhz, 192MB
Model/Manufacturer: Packard Bell Nec
Comment:
How do i change the following code so that it only applies to one day for instance Monday.

------------------------

day = new Date();
hours = day.getUTCHours()*60;
minutes = day.getUTCMinutes();
time = hours + minutes;

if (time < 0) {time = time + 1440}
if (time > 1440) {time = time - 1440}

if(time<480) { // 8:00 am

document.write('<'img src="'day.png'" height="64" width="64" border="1"'>')

} else if(time<960) { //4:00 pm

document.write('<'img src="'afternoon.png" height="64" width="64" border="1"'>')

} else if(time<1440) { //12:00 am

document.write('<'img src="evening.png" height="64" width="64" border="1"'>')

}

------------------


Report Offensive Message For Removal


Response Number 1
Name: Michael J (by mjdamato)
Date: December 13, 2007 at 13:35:02 Pacific
Subject: monday only please!
Reply: (edit)

day = new Date();
hours = day.getUTCHours()*60;
minutes = day.getUTCMinutes();
time = hours + minutes;

if (day.getDay()==1) {

if (time < 0) {time = time + 1440}
if (time > 1440) {time = time - 1440}

if(time<480) { // 8:00 am

var time_img = 'day.png';

} else if(time<960) { //4:00 pm

var time_img = 'afternoon.png';

} else if(time<1440) { //12:00 am

var time_img = 'evening.png';

}


document.write('<'img src="'+time_img+'" height="64" width="64" border="1"'>');

}

Michael J


Report Offensive Follow Up For Removal

Response Number 2
Name: Stephen Allden
Date: December 13, 2007 at 14:55:10 Pacific
Subject: monday only please!
Reply: (edit)
hi the...

if (day.getDay()==1) {

bit doesn't work, the image still displays on other days even though 1 for monday is specified.


Report Offensive Follow Up For Removal

Response Number 3
Name: Michael J (by mjdamato)
Date: December 13, 2007 at 15:20:44 Pacific
Subject: monday only please!
Reply: (edit)
Well, it works for me. If I run that code I don't get any output unless I change the value in the IF statement to 4 (for Thursday).

Now, there is a problem with the document.write() code which was in your original code. There are two additional single quote marks next tot he greater than and less than characters. However, the post won't display properly if you remove them, so I though you did it intentionally.

Here is the correct format for the document.write line with the <> relpaced with [] (so it will display in the forum):

document.write('[img src="'+time_img+'" height="64" width="64" border="1"]');

Michael J


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: monday only please!

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




acer 312T BIOS problem

K7 Turbo possible max fsb?

Pc anywher problem

WinFLP & OE/Outlook2003

Computer resets after a few minutes


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC