日期选择器刷新之后选定的日期就没有了,怎么办呀,请大家帮帮忙!

linchhero 2008-12-08 02:41:50

<script language=javascript>
var myDate=new dateSelector();
myDate.inputName='start_date';
myDate.display();
</script>


我的日期选择器是这样调用的。如果我选了日期作查询条件之后,怎么在翻页后或者刷新后显示我之前所选定的日期。
...全文
184 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
linchhero 2008-12-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 linchhero 的回复:]
http://localhost/DCC/search.asp?getdocno=&getproject=&start_date=2008-11-01&end_date=2008-11-24&Page=13


我翻页的时候传了日期参数。
[/Quote]

怎么去保存这个日期参数呢。请大家帮忙哦。问题一直没解决。
caoacaoca 2008-12-08
  • 打赏
  • 举报
回复
高人N多啊·
sy_binbin 2008-12-08
  • 打赏
  • 举报
回复
http://www.my97.net/dp/demo/
推荐你用用这个吧
linchhero 2008-12-08
  • 打赏
  • 举报
回复
问题还没有解决呀。
linchhero 2008-12-08
  • 打赏
  • 举报
回复
试了好多方法,还是不行呀。
linchhero 2008-12-08
  • 打赏
  • 举报
回复
好像不行呀。
layers2323 2008-12-08
  • 打赏
  • 举报
回复
dateSelector()
不是应该有三个参数吗?你把日期传进去看看。
linchhero 2008-12-08
  • 打赏
  • 举报
回复
呵呵,我在网上找的,所以总是出现问题。
layers2323 2008-12-08
  • 打赏
  • 举报
回复
貌似前两天 见过这段代码。。。
linchhero 2008-12-08
  • 打赏
  • 举报
回复

function getValue(obj,inputObj) //把选择的日期传给输入框
{
var myObj=inputObj.nextSibling.nextSibling.childNodes[0].childNodes[0].cells[2].childNodes;
if(obj.innerHTML)
{
var srm="0"+myObj[2].innerHTML;
var srd="0"+obj.innerHTML;
inputObj.value=myObj[0].innerHTML+"-"+srm.substring(srm.length-2,srm.length)+"-"+srd.substring(srd.length-2,srd.length);
}
inputObj.nextSibling.nextSibling.style.display='none';
for(i=0;i<obj.parentNode.parentNode.parentNode.cells.length;i++)
obj.parentNode.parentNode.parentNode.cells[i].className='';
obj.className='ds_border2'
}

function dsMove(obj)
{
if(event.button==1)
{
var X=obj.clientLeft;
var Y=obj.clientTop;
obj.style.pixelLeft=X+(event.x-DS_x);
obj.style.pixelTop=Y+(event.y-DS_y);
}
}
linchhero 2008-12-08
  • 打赏
  • 举报
回复
我是调用的这个js文件,可以告诉我怎么做吗?实在有点束手无策。

var DS_x,DS_y;
function dateSelector(year,mon,day)
{
if (year > 1990) { var myDate=new Date(year,mon-1,day);}
else{ var myDate=new Date();}

this.year=myDate.getFullYear();
this.month=myDate.getMonth() + 1;
this.date=myDate.getDate();
this.inputName='';
this.display=display;
}

function display()
{
var week=new Array('日','一','二','三','四','五','六');

document.write("<style type=text/css>");
document.write(" .ds_font td,span { font: normal 12px ??; color: #000000; }");
document.write(" .ds_border { border: 0px solid #FFBBFF ; cursor: hand; background-color: #EEAEEE }");
document.write(" .ds_border2 { border: 0px solid #FFBBFF ; cursor: hand; background-color:#FFFFFF}");
document.write("</style>");


var M=new String(this.month);
var d=new String(this.date);

if(M.length==1&&d.length==1){
document.write("<input style='text-align:center;' id='DS_"+this.inputName+"' name='"+this.inputName+"' value='"+this.year+"-0"+this.month+"-0"+this.date+"' title=aaaaa ondblclick='this.readOnly=false;this.focus()' onblur='this.readOnly=true' readonly>");}
else if(M.length==1&&d.length==2){
document.write("<input style='text-align:center;' id='DS_"+this.inputName+"' name='"+this.inputName+"' value='"+this.year+"-0"+this.month+"-"+this.date+"' title=date ondblclick='this.readOnly=false;this.focus()' onblur='this.readOnly=true' readonly>");}
else if(M.length==2&&d.length==1){
document.write("<input style='text-align:center;' id='DS_"+this.inputName+"' name='"+this.inputName+"' value='"+this.year+"-"+this.month+"-0"+this.date+"' title=date ondblclick='this.readOnly=false;this.focus()' onblur='this.readOnly=true' readonly>");}
else if(M.length==2&&d.length==2){
document.write("<input style='text-align:center;' id='DS_"+this.inputName+"' name='"+this.inputName+"' value='"+this.year+"-"+this.month+"-"+this.date+"' title=date ondblclick='this.readOnly=false;this.focus()' onblur='this.readOnly=true' readonly>");}


document.write("<button style='width:60px;height:18px;font-size:12px;margin:1px;border:0px solid #A4B3C8;background-color:#B9D3EE ;' type=button onclick=this.nextSibling.style.display='block' onfocus=this.blur()>Cal</button>");

document.write("<div style='position:absolute;display:none;text-align:center;width:0px;height:0px;overflow:visible' onselectstart='return false;'>");
document.write(" <div style='position:absolute;left:-60px;top:20px;width:142px;height:165px;background-color:#87CEEB;border:0px solid #245B7D;' class=ds_font>");
document.write(" <table cellpadding=0 cellspacing=1 width=140 height=20 bgcolor=#D1EEEE onmousedown='DS_x=event.x-parentNode.style.pixelLeft;DS_y=event.y-parentNode.style.pixelTop;setCapture();' onmouseup='releaseCapture();' onmousemove='dsMove(this.parentNode)' style='cursor:move;'>");
document.write(" <tr align=center>");
document.write(" <td width=12% onmouseover=this.className='ds_border' onmouseout=this.className='' onclick=subYear(this) title='edit it'><<</td>");
document.write(" <td width=12% onmouseover=this.className='ds_border' onmouseout=this.className='' onclick=subMonth(this) title='edit it'><</td>");
document.write(" <td width=52%><b>"+this.year+"</b><b>年</b><b>"+this.month+"</b><b>月</b></td>");
document.write(" <td width=12% onmouseover=this.className='ds_border' onmouseout=this.className='' onclick=addMonth(this) title='edit it'>></td>");
document.write(" <td width=12% onmouseover=this.className='ds_border' onmouseout=this.className='' onclick=addYear(this) title='edit it'>>></td>");
document.write(" </tr>");
document.write(" </table>");

document.write(" <table cellpadding=0 cellspacing=0 width=140 height=20 onmousedown='DS_x=event.x-parentNode.style.pixelLeft;DS_y=event.y-parentNode.style.pixelTop;setCapture();' onmouseup='releaseCapture();' onmousemove='dsMove(this.parentNode)' style='cursor:move;'>");
document.write(" <tr align=center>");
for(i=0;i<7;i++)
document.write(" <td>"+week[i]+"</td>");
document.write(" </tr>");
document.write(" </table>");

document.write(" <table cellpadding=0 cellspacing=2 width=140 bgcolor=#BFEFFF>");
for(i=0;i<6;i++)
{
document.write(" <tr align=center>");
for(j=0;j<7;j++)
document.write(" <td width=10% height=16 onmouseover=if(this.innerText!=''&&this.className!='ds_border2')this.className='ds_border' onmouseout=\"if(this.className!='ds_border2'){var o=this;setTimeout(function(){o.className=''},300)}\" onclick=getValue(this,document.all('DS_"+this.inputName+"'))></td>");
document.write(" </tr>");
}
document.write(" </table>");

document.write(" <span style=cursor:hand onclick=this.parentNode.parentNode.style.display='none'>Close</span>");
document.write(" </div>");
document.write("</div>");

dateShow(document.all("DS_"+this.inputName).nextSibling.nextSibling.childNodes[0].childNodes[2],this.year,this.month)
}

function subYear(obj)
{
var myObj=obj.parentNode.parentNode.parentNode.cells[2].childNodes;
myObj[0].innerHTML=eval(myObj[0].innerHTML)-1;
dateShow(obj.parentNode.parentNode.parentNode.nextSibling.nextSibling,eval(myObj[0].innerHTML),eval(myObj[2].innerHTML))
}

function addYear(obj)
{
var myObj=obj.parentNode.parentNode.parentNode.cells[2].childNodes;
myObj[0].innerHTML=eval(myObj[0].innerHTML)+1;
dateShow(obj.parentNode.parentNode.parentNode.nextSibling.nextSibling,eval(myObj[0].innerHTML),eval(myObj[2].innerHTML))
}

function subMonth(obj)
{
var myObj=obj.parentNode.parentNode.parentNode.cells[2].childNodes;
var month=eval(myObj[2].innerHTML)-1;
if(month==0)
{
month=12;
subYear(obj);
}
myObj[2].innerHTML=month;
dateShow(obj.parentNode.parentNode.parentNode.nextSibling.nextSibling,eval(myObj[0].innerHTML),eval(myObj[2].innerHTML))
}

function addMonth(obj)
{
var myObj=obj.parentNode.parentNode.parentNode.cells[2].childNodes;
var month=eval(myObj[2].innerHTML)+1;
if(month==13)
{
month=1;
addYear(obj);
}
myObj[2].innerHTML=month;
dateShow(obj.parentNode.parentNode.parentNode.nextSibling.nextSibling,eval(myObj[0].innerHTML),eval(myObj[2].innerHTML))
}

function dateShow(obj,year,month)
{
var myDate=new Date(year,month-1,1);
var today=new Date();
var day=myDate.getDay();
var selectDate=obj.parentNode.parentNode.previousSibling.previousSibling.value.split('-');
var length;
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
length=31;
break;
case 4:
case 6:
case 9:
case 11:
length=30;
break;
case 2:
if((year%4==0)&&(year%100!=0)||(year%400==0))
length=29;
else
length=28;
}
for(i=0;i<obj.cells.length;i++)
{
obj.cells[i].innerHTML='';
obj.cells[i].style.color='';
obj.cells[i].className='';
}
for(i=0;i<length;i++)
{
obj.cells[i+day].innerHTML=(i+1);
if(year==today.getFullYear()&&(month-1)==today.getMonth()&&(i+1)==today.getDate())
obj.cells[i+day].style.color='red';
if(year==eval(selectDate[0])&&month==eval(selectDate[1])&&(i+1)==eval(selectDate[2]))
obj.cells[i+day].className='ds_border2';
}
}
layers2323 2008-12-08
  • 打赏
  • 举报
回复
没关系啊,你给他一个初始值,跟js没关系的咯。

当然,你也可以把日期传到js里面,然后在赋值。这样初始化myDate的时候,就要给一个参数。
sy_binbin 2008-12-08
  • 打赏
  • 举报
回复
那就在相应的JS文件里做修改呗
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 linchhero 的回复:]
引用 5 楼 sy_binbin 的回复:
那就在日期表单的值设成翻页的那个参数呗
start_date = request("start_date")
<input name="start_date" type="text" id="start_date" value=" <%=start_date%>" />

如果start_date是我自己用text放上去的话,用value就可以搞定,可是现在那个start_date是我调用JS出来的呀。
[/Quote]

一样的,你JS给start_date这个文本框赋值即可
linchhero 2008-12-08
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 sy_binbin 的回复:]
那就在日期表单的值设成翻页的那个参数呗
start_date = request("start_date")
<input name="start_date" type="text" id="start_date" value=" <%=start_date%>" />
[/Quote]
如果start_date是我自己用text放上去的话,用value就可以搞定,可是现在那个start_date是我调用JS出来的呀。
sy_binbin 2008-12-08
  • 打赏
  • 举报
回复
那就在日期表单的值设成翻页的那个参数呗
start_date = request("start_date")
<input name="start_date" type="text" id="start_date" value="<%=start_date%>" />
linchhero 2008-12-08
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 chinmo 的回复:]
你种情况,只要传递参数即可了
[/Quote]

怎么传递,还请明示哈
linchhero 2008-12-08
  • 打赏
  • 举报
回复
http://localhost/DCC/search.asp?getdocno=&getproject=&start_date=2008-11-01&end_date=2008-11-24&Page=13


我翻页的时候传了日期参数。
  • 打赏
  • 举报
回复
你种情况,只要传递参数即可了
zjsfdxbao 2008-12-08
  • 打赏
  • 举报
回复
得给自身传参数,然后在onload里调用你的日期选择器的设置时间方法
要么你用COOKIE或SESSION,不过都得调用你的日期选择器来设置时间

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧