日期:2014-05-18  浏览次数:20447 次

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>