sm00thtalker80
OSNN One Post Wonder
- Joined
- 27 May 2004
- Messages
- 1
I'm having trouble running this script. My goal is to display a date depending on todays date. For ex. If today is Monday June 7, or Tues. June 8, or Wed. June 9 - I would like the text to display Wednesday June 9. In the 1st script below I can get the script to display 3 dates, which is the 1st basic part of the script but when I try " if " , " else " statements I cant get the script to display correctly as shown in the 2nd script below. I think this will be a simple quick fix but I've racked my brain and can't seem to figure it out. please help...Thanks
1st.
<script type="text/javascript">
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var today = new Date()
var todayInMS = today.getTime()
var inonedays = todayInMS + (60 * 60 * 24 * 0 * 1000)
var intwodays = todayInMS + (60 * 60 * 24 * 1 * 1000)
var inthreedays = todayInMS + (60 * 60 * 24 * 2 * 1000) //
var newdate = new Date(inonedays)
var newdate1 = new Date(intwodays)
var newdate2 = new Date(inthreedays)
document.write("<br>" + weekday[newdate.getDay()] + ", ")
document.write(monthname[newdate.getMonth()] + " ")
document.write(newdate.getDate() + " ")
document.write("<br>" + weekday[newdate1.getDay()] + ", ")
document.write(monthname[newdate1.getMonth()] + " ")
document.write(newdate1.getDate() + " ")
document.write("<br>" + weekday[newdate2.getDay()] + ", ")
document.write(monthname[newdate2.getMonth()] + " ")
document.write(newdate2.getDate() + " ")
//document.write(newdate.getFullYear())
</script>
2nd.
<script type="text/javascript">
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var today = new Date()
var todayInMS = today.getTime()
var inonedays = todayInMS + (60 * 60 * 24 * 0 * 1000)
var intwodays = todayInMS + (60 * 60 * 24 * 1 * 1000)
var inthreedays = todayInMS + (60 * 60 * 24 * 2 * 1000) //
var newdate = new Date(inonedays)
var newdate1 = new Date(intwodays)
var newdate2 = new Date(inthreedays)
if // eg. if today is Monday June 7 - text will display Wednesday June 9
weekday==("Monday","Thursday")
{
document.write(weekday[newdate2.getDay()] + ", ")
document.write(monthname[newdate2.getMonth()] + " ")
document.write(newdate2.getDate() + " ")
}
if
weekday==("Tuesday","Friday")
{
document.write(weekday[newdate1.getDay()] + ", ")
document.write(monthname[newdate1.getMonth()] + " ")
document.write(newdate1.getDate() + " ")
}
if
weekday==("Sunday","Wednesday","Saturday")
{
document.write(weekday[newdate.getDay()] + ", ")
document.write(monthname[newdate.getMonth()] + " ")
document.write(newdate.getDate() + " ")
}
</script>
Thank you for your time.
Brian
1st.
<script type="text/javascript">
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var today = new Date()
var todayInMS = today.getTime()
var inonedays = todayInMS + (60 * 60 * 24 * 0 * 1000)
var intwodays = todayInMS + (60 * 60 * 24 * 1 * 1000)
var inthreedays = todayInMS + (60 * 60 * 24 * 2 * 1000) //
var newdate = new Date(inonedays)
var newdate1 = new Date(intwodays)
var newdate2 = new Date(inthreedays)
document.write("<br>" + weekday[newdate.getDay()] + ", ")
document.write(monthname[newdate.getMonth()] + " ")
document.write(newdate.getDate() + " ")
document.write("<br>" + weekday[newdate1.getDay()] + ", ")
document.write(monthname[newdate1.getMonth()] + " ")
document.write(newdate1.getDate() + " ")
document.write("<br>" + weekday[newdate2.getDay()] + ", ")
document.write(monthname[newdate2.getMonth()] + " ")
document.write(newdate2.getDate() + " ")
//document.write(newdate.getFullYear())
</script>
2nd.
<script type="text/javascript">
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var today = new Date()
var todayInMS = today.getTime()
var inonedays = todayInMS + (60 * 60 * 24 * 0 * 1000)
var intwodays = todayInMS + (60 * 60 * 24 * 1 * 1000)
var inthreedays = todayInMS + (60 * 60 * 24 * 2 * 1000) //
var newdate = new Date(inonedays)
var newdate1 = new Date(intwodays)
var newdate2 = new Date(inthreedays)
if // eg. if today is Monday June 7 - text will display Wednesday June 9
weekday==("Monday","Thursday")
{
document.write(weekday[newdate2.getDay()] + ", ")
document.write(monthname[newdate2.getMonth()] + " ")
document.write(newdate2.getDate() + " ")
}
if
weekday==("Tuesday","Friday")
{
document.write(weekday[newdate1.getDay()] + ", ")
document.write(monthname[newdate1.getMonth()] + " ")
document.write(newdate1.getDate() + " ")
}
if
weekday==("Sunday","Wednesday","Saturday")
{
document.write(weekday[newdate.getDay()] + ", ")
document.write(monthname[newdate.getMonth()] + " ")
document.write(newdate.getDate() + " ")
}
</script>
Thank you for your time.
Brian