HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 10th, 2000, 01:15 PM
atarbaer atarbaer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 17 atarbaer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

I have some Javascript code which automatically inserts a date into a form, which corresponds to Monday of the previous week. This code runs fine on Microsoft IE, but does not run at all on Netscape. I have pasted the relevant portions of the code below. Your help would be greatly appreciated.

Thanks!

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

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin

var today = new Date();
var day1 = today.getDate()-13;
var month = today.getMonth() + 1;
var year = today.getYear();
if (year < 2000) // Y2K Fix, Isaac Powell
year = year + 1900;
var offset = today.getDay();
var week;
if(offset != 0) {
day1 = day1 - offset;
if ( day1 < 1) {
if ( month == 1) day1 = 31 + day1;
if (month == 2) day1 = 31 + day1;
if (month == 3) {
if (( year == 00) | | ( year == 04)) {
day1 = 29 + day1;
}
else {
day1 = 28 + day1;
}
}
if (month == 4) day1 = 31 + day1;
if (month == 5) day1 = 30 + day1;
if (month == 6) day1 = 31 + day1;
if (month == 7) day1 = 30 + day1;
if (month == 8) day1 = 31 + day1;
if (month == 9) day1 = 31 + day1;
if (month == 10) day1 = 30 + day1;
if (month == 11) day1 = 31 + day1;
if (month == 12) day1 = 30 + day1;
if (month == 1) {
month = 12;

year = year - 1;
}
else {
month = month - 1;
}
}
}


week1 = month + "-" + day1 + "-" + year;

// more code here

-->
</SCRIPT>

</HEAD>
<BODY>
<FORM>

<TABLE>
<TBODY>
<TR>
<TD> The following questions refer to the week beginning <SCRIPT
LANGUAGE="JavaScript"><!--
document.write(week1);
-->
</script>
</td>
</tr>
</TBODY>
</table>
</form>
</body>

-----------------------------------
Any suggestions?

Reply With Quote
  #2  
Old September 10th, 2000, 02:59 PM
kenowhere kenowhere is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 34 kenowhere User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
This code needs to add a JavaScript comments line after the HTML comments --> so Netscape won't pop-up errors. So you need to modify all --> inside the JavaScript tags to // -->. If you want, you can use SSI includes to make your code work on all the browsers. All you have to do is make your .html file an .shtml file so you're able to use the SSI includes. Then use <!-- #echo var="DATE_LOCAL" --> in your HTML. You can also format the output of the date by using <!-- config timefmt="Date" --> where date could equal %a, %d, %b, %y. or all of those to get the proper format. I hope this solved your problem.

Devin Hendricks www.sitesuwant.com
sitesuwant@sitesuwant.com

Reply With Quote
  #3  
Old September 10th, 2000, 04:35 PM
atarbaer atarbaer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 17 atarbaer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks -- that fixed it!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Updating a date in a form: works in IE, not Netscape


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway