hi wanted to ask whether you guys know anythin wrong with this code..
this code should be able to select and de-select (change a class) of a <TD> corresponding to the checked checkboxes.. if selected the class is daySelected and if its de-selected, the class is dayNotAllocated..
The table contains 21 cells which corresponds to the date until 3 weeks ahead from the date specified in a hidden input which is [B]document.calendar.fromDate.value
[CODE] function rateGlobalSelect() {
var startDateString = [B]document.calendar.fromDate.value;[/B]
var beginDatePre = Date.parse(startDateString);
var beginDate = new Date(beginDatePre);
//var beginDay = beginDate.getDay();
var monCheck = document.getElementById(‘mon’).checked;
var tueCheck = document.getElementById(‘tue’).checked;
var wedCheck = document.getElementById(‘wed’).checked;
var thuCheck = document.getElementById(‘thu’).checked;
var friCheck = document.getElementById(‘fri’).checked;
var satCheck = document.getElementById(‘sat’).checked;
var sunCheck = document.getElementById(‘sun’).checked;
var dayArray = new Array();
dayArray[0] = monCheck;
dayArray[1] = tueCheck;
dayArray[2] = wedCheck;
dayArray[3] = thuCheck;
dayArray[4] = friCheck;
dayArray[5] = satCheck;
dayArray[6] = sunCheck;
var refRe = /ra(S+)_(S+)/;
var countElement = document.calendar.elements.length;
for (i=0; i < countElement; i++) {
var dayRef = document.calendar.elements[i];
var curEl = dayRef.name;
var matches = refRe.exec(curEl);
if (matches) {
var rateTypeId = parseInt(matches[1]);
var daysFromPeriodStart = parseInt(matches[2]);
// find current date here using startdate + daysFromPeriodStart
var curDay = new Date((daysFromPeriodStart * 1000 * 60 * 60 * 24) + beginDate.getTime());
var selectedDay = curDay.getDay();
if (dayArray[selectedDay]) {
//set class to selected
dayRef.className = ‘daySelected’;
//var selectedDay = beginDay + daysFromPeriodStart;
}
}
}
}
thank you for the time.. ?