首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

value 如何取不到值呢?请一下

2011-12-12 
value 怎么取不到值呢?请高手指点一下;SCRIPT languagejavascriptfunction btnLogin_Click(objPassword

value 怎么取不到值呢?请高手指点一下;
<SCRIPT language=javascript >
function btnLogin_Click(objPassword)
{
var a = objPassword;
var b = "\xa3\xac\xa1\xa3";
var c = "fdjf,jkgfkl";
var s = a + b + c;
var r = MD5(s);
return r;
}
</SCRIPT>
<input type=hidden value='btnLogin_Click(<%=ViewState["GameUserName"]%>)' name=UserID >我想让value 等于上面函数的返回值,每次原代码都是value='btnLogin_Click(11)'请问是什么道理?

[解决办法]
修改
<SCRIPT language=javascript > 
function btnLogin_Click(objPassword) 

var a = objPassword; 
var b = "\xa3\xac\xa1\xa3 "; 
var c = "fdjf,jkgfkl "; 
var s = a + b + c; 
var r = MD5(s); 
return r; 

var r=btnLogin_Click( <%=ViewState[ "GameUserName "]%> );
document.getElementId("UserID").setAttribute ("value",r);
</SCRIPT> 
<input type=hidden value= '' id="UserID" name="userid"/>


[解决办法]
给Input给个ID,后面要用。
<input type="text" value=' <%="btnLogin_Click(" + ViewState["GameUserName"] + ")"%> '
name="UserID" id="UserID" />

在后台调用前台的JS函数:

 Page.ClientScript.RegisterStartupScript(this.GetType(), "begin", "<script>document.getElementById('UserID').value=btnLogin_Click(\"" + ViewState["GameUserName"] + "\");</script>");
[解决办法]

HTML code
<input       type=hidden               value=   ' '       id= "UserID "       name= "userid "/><!-- 这个得放到前面来,不然取不到... (JS放到这个后面) --><SCRIPT       language=javascript           >  function       btnLogin_Click(objPassword)  {  var       a       =       objPassword;  var       b       =       "\xa3\xac\xa1\xa3   ";  var       c       =       "fdjf,jkgfkl   ";  var       s       =       a       +       b       +       c;  var       r       =       MD5(s);  return       r;  }  var   r=btnLogin_Click(   <%=ViewState[   "GameUserName   "]%>   );document.getElementId( "UserID ").setAttribute   ( "value ",r);</SCRIPT> 

热点排行