Javascript How-ToAsk your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
using the following code to build a list of Tuesdays for the current year. Script starts to error after the 5th iteration. If I use any of the counter numbers instead of the var counter the script will find the appropriate day. With the var counter I have errors. Displaying the var counter to detect any errors.
<html>
<body>
<script>
var meetingDate = new Date("1 Jan 2004");
var counter = 6;
while (counter < 366 )
{
meetingDate.setDate(counter);
var dateNow = meetingDate.getDate();
var monthNow = meetingDate.getMonth() + 1;
var yearNow = meetingDate.getFullYear();
note the output fron week 5 on. this is where the problems start
Tuesday 1/6/2004- counter is 6
Tuesday 1/13/2004- counter is 13
Tuesday 1/20/2004- counter is 20
Tuesday 1/27/2004- counter is 27
Tuesday 2/3/2004- counter is 34
Tuesday 3/12/2004- counter is 41
Tuesday 4/17/2004- counter is 48
Tuesday 5/25/2004- counter is 55
Tuesday 7/1/2004- counter is 62
Tuesday 9/7/2004- counter is 69
Tuesday 11/15/2004- counter is 76
Tuesday 1/22/2005- counter is 83
Tuesday 3/31/2005- counter is 90
Tuesday 6/5/2005- counter is 97
Tuesday 9/12/2005- counter is 104
Tuesday 12/20/2005- counter is 111
Tuesday 3/28/2006- counter is 118
Tuesday 7/3/2006- counter is 125
Tuesday 11/9/2006- counter is 132
Tuesday 3/19/2007- counter is 139
Tuesday 7/24/2007- counter is 146
Tuesday 11/30/2007- counter is 153
Tuesday 4/8/2008- counter is 160