日期:2014-05-16  浏览次数:20347 次

jquery 为啥赋值错误
本帖最后由 dtt3401885 于 2013-06-28 16:09:29 编辑
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<script type="text/javascript" src="http://www.shopbest.cn/js/jquery.min.js"></script>
<script type="text/javascript" src="http://www.shopbest.cn/js/jquery.js"></script>

<title>HELPDESK</title>

<script type="text/javascript">

window.onload=nameandpass()
function nameandpass(){
var asiacomname=getCookie('asiacomname')
var asiacompass=getCookie('asiacompass')
alert(asiacomname)
alert(asiacompass)
//document.getElementById("j_username").value=asiacomname
jQuery("#j_username").val(asiacomname)//无法赋值
jQuery("#j_password").val(asiacompass)//无法赋值
}

function getCookie(objName){//获取指定名称的cookie的值
 var arrStr = document.cookie.split("; ");
 for(var i = 0;i < arrStr.length;i++){
 var temp = arrStr[i].split("=");
 if(temp[0] == objName) 
     return unescape(temp[1]);
 } 
 }
function savecookie(){
  var name=jQuery("#j_username").val()
  var pass=jQuery("#j_password").val()
  addCookie('asiacomname',name)
   addCookie('asiacompass',pass)
}
function addCookie(objName,objValue){//添加cookie
var str = objName + "=" + escape(objValue);
//为0时不设定过期时间,浏览器关闭时cookie自动消失
var date = new Date();
var ms = 3*3600*1000;
date.setTime(date.getTime() + ms);
str += "; expires=" + date.toGMTString();
document.cookie = str;
}
</script>

</head>
<body>
    <form action='${postUrl}' id="loginForm" method="post" style=" display:block;height:100%;">
   
    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" style="height:100%;">  
<tr>  
<td align="center" valign="middle">
      <table border="0" align="center" cellpadding="0" cellspacing="0"
style=" height:433px; width:881px; background:url(../Platform/Images/loginbg-asiacom.png) no-repeat 0px 0px;">