asp如何让回调的页面保持选择的状态,
<label> 运行情况:
<select name= "yxqk " id= "yxqk ">
<option value= "a "> a </option>
<option value= "b "> b </option>
<option value= "c "> c </option>
</select>
</label>
比如我选择了b,查询後页面重新加载
下拉列表又变为a 了
我希望选择了b,页面重新加载后显示还是b.
------解决方案-------------------- <%
ywqk = Request( "ywqk ")
%>
<select name= "yxqk " id= "yxqk ">
<option value= "a " <% If ywqk = "a " Then Response.Write "selected= 'selected ' "%> > a </option>
<option value= "b " <% If ywqk = "b " Then Response.Write "selected= 'selected ' "%> > b </option>
<option value= "c " <% If ywqk = "c " Then Response.Write "selected= 'selected ' "%> > c </option>
</select>
------解决方案--------------------可以换一种思路嘛,干嘛非要ASP来实现啊,JavaScript就可以实现了,在提交之前把选择或填写的值存入客户端的cookies,然后重新返回该页面的时候,再获取值,来填入、选择值
javascript:
var cookie = {
get : function(){},//获取cookie
set : function(){}//设置cookie
}
在提交的页面中这样写:
window.onload = function(){
if(document.referrer== '返回的页面 '){
document.getElementById( 'id1 ').value = cookie.get( 'xxx ');
...
}
}
返回的时候就有了,这种不需要和服务器间传送大量数据
------解决方案--------------------少了一点,就是当你提交的时候,要把值存入cookie
onsubmit = function(){
cookie.set( 'id1 ',document.getElementById( 'id1 ').value );
}
------解决方案--------------------以CurrentDate为例
表单中加入 <input type= "hidden " name= "CurrentDate ">
递交时执行JS
var list = document.getElementById( "DTPicker1 ").getElementsByTagName( "PARAM ");
var val = null;
for(var i=0;i <list.length;i++){
if(list[i].name== "CurrentDate "){val=list[i].value;break;}
}
document.formname.CurrentDate.value=val;
document.formname.submit();
递交后
<%
CurrentDate = Request( "CurrentDate ")
%>
...
<%
If CurrentDate <> " " Then
%>
<param name= "CurrentDate " value= " <%=CurrentDate%> ">
<%
Else
%>
<param name= "CurrentDate " value= "39083 ">
<%
End If
%>