<script language="JavaScript">
function addCookie(name,value,expireHours)
{
var cookieString=name+"="+escape(value);
//判断是否设置过期时间
if(expireHours>0){
var date=new Date();
date.setTime(date.getTime+expireHours*3600*1000);
cookieString=cookieString+"; expire="+date.toGMTString();
}
document.cookie=cookieString;
}
function getCookie(name){
var strCookie=document.cookie;
var arrCookie=strCookie.split("; ");
for(var i=0;i<arrCookie.length;i++){
var arr=arrCookie[i].split("=");
if(arr[0]==name)return unescape(arr[1]);
}
return "";
}
function deleteCookie(name)
{
var date=new Date();
date.setTime(date.getTime()-10000);
document.cookie=name+"=v; expire="+date.toGMTString();
}
function bum()
{
if (document.frm.ckum.checked==true)
{
addCookie("username",document.frm.um.value,10);
document.frm.um.value=getCookie("username");
}
else
{
deleteCookie("username");
document.frm.um.value='';
}
}
function bmm()
{
if (document.frm.ckmm.checked==true)
{
addCookie("username",document.frm.mm.value,10);
document.frm.mm.value=getCookie("password");
}
else
{
deleteCookie("password");
document.frm.mm.value='';
}
}
</script>
<form action="index.asp?act=zhixing" name="frm" method="post" onsubmit="return checkon();">
<table border="1" align="center" cellpadding="10" cellspacing="10">
<tr>
<td>用户名:</td>
<td>
<input type="text" name="um" value="">
</td>
</tr>
<tr><td>
密码:</td>
<td><input type="password" name="mm" value=""></td>
</tr>
<tr><td>
<input type="reset" name="reset" value="重入"></td>
<td><input type="submit" name="submit" value="登入" onclick="ll();"></td>
</tr>
<tr>
<td><input type="checkbox" name="ckum" onclick="bum()">保存用户名</td>
<td><input type="checkbox" name="ckmm" onclick="bmm()">保存密码</td>
</tr>
</table>
</form>
以上为保存用户名和密码的COOKIE代码,不知道为什么就是不成功!请教JAVASCRIPT的高手帮忙修改下!让它可以正常使用,非常感谢!