//先转换成js认识的日期
var kssj =new Date(kssj);//开始时间
var jssj =new Date(jssj);//结束时间
/* var y = kssj.substring(0, 4);
// 得到月部分
var m = kssj.substring(5, 7);
// 得到日部分
var d = kssj.substring(8, 10);
var kssj = new Date(y + '-' + m + '-' + d); */
//给日期类对象添加日期差方法,返回日期与diff参数日期的时间差,单位为天
//开始计算两者相差的时间
Date.prototype.diff = function(date){
return (this.getTime() - date.getTime())/(24 * 60 * 60 * 1000);
};
//用结束时间去减去开始时间 得到相减的天数
var diff = jssj.diff(kssj);
//根据要求 当天不算需要减1
var jieke = diff-1;
//根据得到的天数循环 每次累加1,来获取冲添加到结束的日期
//先定义一个空数组 来存储所有得到的所有日期
var syrq = new Array();
for (var i = 0; i < jieke; i++) {
kssj.setDate(kssj.getDate() + 1);
//实例一个时间对象;
var oDate = new Date(kssj);
//获取系统的年;
var y=oDate.getFullYear();
//获取系统月份,由于月份是从0开始计算,所以要加1
var m=oDate.getMonth()+1;
// 获取系统日
var d=oDate.getDate();
var zsrq=(y + '-' + m + '-' + d);
syrq[i]=zsrq;
}
nui.confirm("是否填写住宿信息","温馨提示",
function(e){
if(e=="cancel" || e=="close")return;
nui.open({
url: "<%=request.getContextPath() %>/PeiXunZhongXin/jinqkb/jinqkb_zsxx.jsp?syrq="+syrq,
title: "住宿信息",
width : 800,
height : 500,
ondestroy : function(action) {
grid.reload();
}
});
});
下一个页面是把相差的日期赋值到多选框上
//获取父页面传过来的字符串
var syrq = '<%=request.getParameter("syrq") %>';
//把字符串截取成数组根据","截取
var result = syrq.split(",");
//获取父页面传过的参数
var id = '<%=request.getParameter("id") %>';
//获取form表单
var form = new nui.Form("form");
//优先加载function方法内部的
$(function(){
LoadXX();
});
//跟据loadxx方法去循环插入组
function LoadXX(){
var leg=0;
//取出长度
var lengths = result.length;
//长度超过11,按11进行计算 否者 按原来的长度计算
if(lengths>11){
leg =11;
}else{
leg= lengths;
}
//进入循环 用leg的长度来 决定页面的值
for(var i=0;i<leg;i++){
//方法为引用
var zssj=result[i];
//i第一次是0+1 赋值到页面id里面
var ID = i+1;
//判断qq 等于几页面 出来几个多选框 自己编写请暂时不要模仿
if(lengths == 1){
XX = { id: ID, name: result[0]};
}else if(lengths == 2){
XX = [{id: ID, name: result[0]},{id: ID, name: result[1]}];
}else if(lengths == 3){
XX = [{id: ID, name: result[0]},{id: ID, name: result[1]},{id: ID, name: result[2]}];
}else if(lengths == 4){
XX = [{ id: ID, name:result[0]},{id: ID, name: result[1]},{id: ID, name: result[2]},{id: ID, name: result[3]}];
}else if(lengths == 5){
XX = [{ id: ID, name:result[0]},{id: ID, name: result[1]},{id: ID, name: result[2]},{id: ID, name: result[3]},{id: ID, name: result[4]}];
}else if(lengths == 6){
XX = [{ id: ID, name:result[0]},{id: ID, name: result[1]},{id: ID, name: result[2]},{id: ID, name: result[3]},{id: ID, name: result[4]},{id: ID, name: result[5]}];
}else if(lengths == 7){
XX = [{ i8d: ID, name:result[0]},{id: ID, name: result[1]},{id: ID, name: result[2]},{ id: ID, name:result[3]},{id: ID, name: result[4]},{id: ID, name: result[5]},{id: ID, name: result[6]}];
}else if(lengths == 8){
XX = [{ id: ID, name:result[0]},
{id: ID, name: result[1]},
{id: ID, name: result[2]},
{id: ID, name:result[3]},
{id: ID, name: result[4]},
{id: ID, name: result[5]},
{id: ID, name: result[6]},
{id: ID, name: result[7]}];
}else if(lengths == 9){
XX = [{ id: ID, name:result[0]},
{id: ID, name: result[1]},
{id: ID, name: result[2]},
{id: ID, name:result[3]},
{id: ID, name: result[4]},
{id: ID, name: result[5]},
{id: ID, name: result[6]},
{id: ID, name: result[7]},
{id: ID, name: result[8]}];
}else if(lengths == 10){
XX = [{ id: ID, name:result[0]},
{id: ID, name: result[1]},
{id: ID, name: result[2]},
{id: ID, name:result[3]},
{id: ID, name: result[4]},
{id: ID, name: result[5]},
{id: ID, name: result[6]},
{id: ID, name: result[7]},
{id: ID, name: result[8]},
{id: ID, name: result[9]}];
}else if(lengths == 11){
XX = [{ id: ID, name:result[0]},
{id: ID, name: result[1]},
{id: ID, name: result[2]},
{id: ID, name:result[3]},
{id: ID, name: result[4]},
{id: ID, name: result[5]},
{id: ID, name: result[6]},
{id: ID, name: result[7]},
{id: ID, name: result[8]},
{id: ID, name: result[9]},
{id: ID, name: result[10]}];
}
//取input框id
var ZhuSu = nui.get("zssj");
//根据id加载 自己编写的方法
ZhuSu.load(XX);
}
}
本文转自12691034博客51CTO博客,原文链接http://blog.51cto.com/12701034/1929238如需转载请自行联系原作者
笑容掩饰爱