`
uule
  • 浏览: 6308660 次
  • 性别: Icon_minigender_1
  • 来自: 一片神奇的土地
社区版块
存档分类
最新评论

一个星期中某一天存在即显示的思路

    博客分类:
  • JSP
F# 
阅读更多

1、

days:  1,2,3,4,5,6,0     //数据库中的每条数据对应一条记录
        或1,2,3,4,0
        或5,6
         ...

 

rateRecord[rateRecord.length] = (isDayExist(days, 1)==true) ? '<td style="color:#4a6129; width:20px; text-align:center;">M</td>' : '<td style="font-weight:bold;font-size:14px;">&nbsp; </td>';
rateRecord[rateRecord.length] = (isDayExist(days, 2)==true) ? '<td style="">T</td>' : '<td style="">&nbsp; </td>';
rateRecord[rateRecord.length] = (isDayExist(days, 3)==true) ? '<td style="">W</td>' : '<td style="">&nbsp; </td>';
rateRecord[rateRecord.length] = (isDayExist(days, 4)==true) ? '<td style="">T</td>' : '<td style="">&nbsp; </td>';
rateRecord[rateRecord.length] = (isDayExist(days, 5)==true) ? '<td style="">F</td>' : '<td style="">&nbsp; </td>';
rateRecord[rateRecord.length] = (isDayExist(days, 6)==true) ? '<td style="">S</td>' : '<td style="">&nbsp; </td>';
rateRecord[rateRecord.length] = (isDayExist(days, 0)==true) ? '<td style="">S</td>' : '<td style="">&nbsp; </td>';

 

//如果该条记录某天存在
function isDayExist(days, dayNo) {
		for (var i=0; i<days.length; i++) {
			if (days[i] == dayNo) return true;
		}
		return false;
	}

 

 

2、

 

<td>
<table style="margin:auto; width:40%;text-align:left;" cellpadding="0" cellspacing="0" >
	<tr>
		<td style="text-align:center;">All</td>
		<td style="text-align:center;">Mon</td>
		<td style="text-align:center;">Tue</td>
		<td style="text-align:center;">Wed</td>
		<td style="text-align:center;">Thu</td>
		<td style="text-align:center;">Fri</td>
		<td style="text-align:center;">Sat</td>
		<td style="text-align:center;">Sun</td>
	</tr>
	<tr>
		<td style="text-align:center;"><input id="idAllWeek" name="idAllWeek" type="checkbox" onclick='checkAllWeekStatus(this);' /></td>
		<td style="text-align:center;"><input id="mon" name="mon" type="checkbox" /></td>
		<td style="text-align:center;"><input id="tue" name="tue" type="checkbox" /></td>
		<td style="text-align:center;"><input id="wed" name="wed" type="checkbox" /></td>
		<td style="text-align:center;"><input id="thu" name="thu" type="checkbox" /></td>
		<td style="text-align:center;"><input id="fri" name="fri" type="checkbox" /></td>
		<td style="text-align:center;"><input id="sat" name="sat" type="checkbox" /></td>
		<td style="text-align:center;"><input id="sun" name="sun" type="checkbox" /></td>
	</tr>
</table>
</td>

 

function saveOrUpdateWeek(){
			var daysStr = "";
			var days = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
			for (var i=0; i<days.length; i++) {
				if (jQuery("#"+days[i]).attr("checked") == true) {
				   daysStr += i+",";
				}
			}
			daysStr = daysStr.substring(0,daysStr.length-1);
			jQuery("#dayOfWeek").val(daysStr);
		}
		
		function initDayOfWeek(str){
			jQuery("input[type='checkbox']").attr("checked",false);
			var days = str.split(",");
			if(days.length == 7) {
				jQuery("#idAllWeek").attr("checked",true);
			}else{
				jQuery("#idAllWeek").attr("checked",false);
			}
			for(var i =0;i<days.length;i++){
				switch (days[i]) {
					case '0': jQuery('#sun').attr("checked",true); break;
					case '1': jQuery('#mon').attr("checked",true); break;
					case '2': jQuery('#tue').attr("checked",true); break;
					case '3': jQuery('#wed').attr("checked",true); break;
					case '4': jQuery('#thu').attr("checked",true); break;
					case '5': jQuery('#fri').attr("checked",true); break;
					case '6': jQuery('#sat').attr("checked",true); break;
				}
			}
		}
		
		function checkAllWeekStatus( chkObj ) {
			if ( chkObj.checked ) { 
				jQuery('#mon').attr("checked",true);
				jQuery('#tue').attr("checked",true);
				jQuery('#wed').attr("checked",true);
				jQuery('#thu').attr("checked",true);
				jQuery('#fri').attr("checked",true);
				jQuery('#sat').attr("checked",true);
				jQuery('#sun').attr("checked",true);
			} else {
				jQuery('#mon').attr("checked",false);
				jQuery('#tue').attr("checked",false);
				jQuery('#wed').attr("checked",false);
				jQuery('#thu').attr("checked",false);
				jQuery('#fri').attr("checked",false);
				jQuery('#sat').attr("checked",false);
				jQuery('#sun').attr("checked",false);
			}
		}
 

。。。。。。。

 

 

 
  • 大小: 23 KB
  • 大小: 2.4 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics