|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Thanks -- that fixed it!
|
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Updating a date in a form: works in IE, not Netscape |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|