java菜鸟请教select下拉框的问题,向各位大神求教
请问,一个页面被提交,或这被刷新,请问怎么才能保存select里被选中的值?十万火急,在线等,谢谢各位大神...
请问,一个页面被提交,或这被刷新,请问怎么才能保存select里被选中的值?十万火急,在线等,谢谢各位大神
展开
展开全部
写入cookie
后台传回获取
html5新特性
ajax无刷新提交
追问
我是新手,能写点代码吗?谢谢了
追答
// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
}
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
// The hours parameter is optional; if hours is left out, the cookie value expires at the end of the visitor's browser session.
function writeCookie(name, value, hours)
{
var expire = "";
if(hours != null)
{
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询