JavaScript写的日历中的一段代码,看不懂,求解释
functionnewCalendar(){varparseYear=parseInt(document.all.Year.options[document.all.Ye...
function newCalendar() {
var parseYear = parseInt(document.all.Year.options[document.all.Year.selectedIndex].value);
var newCal = new Date(parseYear, document.all.Month.selectedIndex, 1);
var day = -1;
var startDay = newCal.getDay();
var daily = 0;
if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))
day = today.day;
var tableCal = document.all.calendar;
var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());
for (var intWeek = 1; intWeek < tableCal.rows.length;intWeek++)
for (var intDay = 0;intDay < tableCal.rows[intWeek].cells.length;intDay++)
{
var cell = tableCal.rows[intWeek].cells[intDay];
if ((intDay == startDay) && (0 == daily))
daily = 1;
var nowtime = new getToday();
if(day==daily) //今天,调用今天的Class
{
cell.style.background='#6699CC';
cell.style.color='yellow';
cell.style.fontWeight='bold';
}
else if(intDay==6) //周六
cell.style.color='green';
else if (intDay==0) //周日
cell.style.color='red';
if ((daily > 0) && (daily <= intDaysInMonth))
{
cell.innerText = daily;
daily++;
}
else
cell.innerText = "";
}
}
day是什么,daily是什么,这段代码看不懂...我只是想改一下今天之后的日期不能点,怎么做啊这 展开
var parseYear = parseInt(document.all.Year.options[document.all.Year.selectedIndex].value);
var newCal = new Date(parseYear, document.all.Month.selectedIndex, 1);
var day = -1;
var startDay = newCal.getDay();
var daily = 0;
if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))
day = today.day;
var tableCal = document.all.calendar;
var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());
for (var intWeek = 1; intWeek < tableCal.rows.length;intWeek++)
for (var intDay = 0;intDay < tableCal.rows[intWeek].cells.length;intDay++)
{
var cell = tableCal.rows[intWeek].cells[intDay];
if ((intDay == startDay) && (0 == daily))
daily = 1;
var nowtime = new getToday();
if(day==daily) //今天,调用今天的Class
{
cell.style.background='#6699CC';
cell.style.color='yellow';
cell.style.fontWeight='bold';
}
else if(intDay==6) //周六
cell.style.color='green';
else if (intDay==0) //周日
cell.style.color='red';
if ((daily > 0) && (daily <= intDaysInMonth))
{
cell.innerText = daily;
daily++;
}
else
cell.innerText = "";
}
}
day是什么,daily是什么,这段代码看不懂...我只是想改一下今天之后的日期不能点,怎么做啊这 展开
2个回答
展开全部
代码帮你解释下 后面问题没看懂
function newCalendar() {
var parseYear = parseInt(document.all.Year.options[document.all.Year.selectedIndex].value);
// 获取年月下拉框的值,生成一个日期
var newCal = new Date(parseYear, document.all.Month.selectedIndex, 1);
var day = -1;
var startDay = newCal.getDay(); //星期几
var daily = 0; // 生成日历时,不断++,输出日期到日历上的值
// 比如today = {year:2014,month:9,day:20};
if ((today.year == newCal.getFullYear()) && (today.month == newCal.getMonth()+1))
// 如果下拉框选择的年月值=现在年月(2014,9),则保存今天日期,比如现在是20号,生成日历时会将今天高亮显示
day = today.day;
var tableCal = document.all.calendar;
var intDaysInMonth = getDays(newCal.getMonth(), newCal.getFullYear()); //
for (var intWeek = 1; intWeek < tableCal.rows.length; intWeek++)
for (var intDay = 0; intDay < tableCal.rows[intWeek].cells.length; intDay++) {
var cell = tableCal.rows[intWeek].cells[intDay];
if ((intDay == startDay) && (0 == daily))
daily = 1; // 判断从星期几开始打印
//var nowtime = new getToday();
if (day == daily) //今天,调用今天的Class
{
cell.style.background = '#6699CC';
cell.style.color = 'yellow';
cell.style.fontWeight = 'bold';
} else if (intDay == 6) //周六
cell.style.color = 'green';
else if (intDay == 0) //周日
cell.style.color = 'red';
if ((daily > 0) && (daily <= intDaysInMonth)) {
cell.innerText = daily; //打印日期1,2,3...31
daily++;
} else
cell.innerText = "";
}
}
追问
真是好人,谢了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询