JS如何赋值给文本框?
展开全部
<script>
function ReadCookie(){
alert(getCookie("UserEmail").split(","));
}
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]);
}
}
var cookie_val = getCookie("UserEmail");
window.onload=function(){document.getElementById("mail").value=cookie_val}
</script>
<form name="addform" action="" method="get">
<input type="button" value="查看保存的COOKIES值" onclick="ReadCookie()">
<input type="text" id="mail" value="" name="mail" onclick="ReadCookie()">
</form>
function ReadCookie(){
alert(getCookie("UserEmail").split(","));
}
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]);
}
}
var cookie_val = getCookie("UserEmail");
window.onload=function(){document.getElementById("mail").value=cookie_val}
</script>
<form name="addform" action="" method="get">
<input type="button" value="查看保存的COOKIES值" onclick="ReadCookie()">
<input type="text" id="mail" value="" name="mail" onclick="ReadCookie()">
</form>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询