My attachment displays todays date. Below it is a ‘next week’ button which should give next week’s date when pressed once. When once again should give date after 2 weeks and so on.
My logic is to count no. of clicks on the button in function clickCount(f) and give this value to function updateFields(n) to give next weeks date.
But my program doesn’t run. ?
Help !
Here’s my code. I have even attached it !
[code]
<html>
<head>
<script type=”text/javascript”>
var count=0;
function clickCount(f) {
count += 1;
f.value = count;
}
function makeArray0() {
for (i = 0; i<makeArray0.arguments.length; i++)
this[i] = makeArray0.arguments[i];
}
var days = new makeArray0(‘Sunday’,’Monday’,’Tuesday’,’Wednesday’,’Thursday’,’Friday’,’Saturday’);
function makeDate(x) {
var days = new makeArray0(‘Sunday’,’Monday’,’Tuesday’,’Wednesday’,’Thursday’,’Friday’,’Saturday’);
now = new Date();
now = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0); // midnight
var theDay = new Date(now.getTime()+(x*24*60*60*1000));
return days[theDay.getDay()] + ‘ ‘ + theDay.getDate() + ‘-‘ + (theDay.getMonth()+1) + ‘-‘ + theDay.getFullYear();
}
function updateFields(n) {
for(var i=0; i <= 6; i++) {
document.getElementById(“date”+i).innerHTML = makeDate(i+n);
}
}
</script>
<head>
<body>
<table width=”146″ height=”81″ border=”1″ align=”center”>
<tr>
<td width=”92″ id=”date1″><script type=”text/javascript”>document.write(makeDate(0));</script></td>
</tr>
<tr>
<td align=”center”>
<form>
<input type=”button” value=”Next Week” onClick=”clickCount(form)”>
<a href=”#” onclick=”updateFields(7 * clickCount(form));return false;”></a>
<form>
</td>
</tr>
</table>
</body>
</html>