JS如何赋值给文本框?
<script>functionReadCookie(){alert(getCookie("UserEmail").split(","));}functiongetCoo...
<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");
</script>
<form name="addform" action="" method="get">
<input type="button" value="查看保存的COOKIES值" onclick="ReadCookie()">
<input type="text" id="txt1" value="" name="mail" onclick="ReadCookie()">
</form>
如何把cookie_val 的值赋给下面那个的文本框,直接显示出来,现在是点击下才显示 展开
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");
</script>
<form name="addform" action="" method="get">
<input type="button" value="查看保存的COOKIES值" onclick="ReadCookie()">
<input type="text" id="txt1" value="" name="mail" onclick="ReadCookie()">
</form>
如何把cookie_val 的值赋给下面那个的文本框,直接显示出来,现在是点击下才显示 展开
展开全部
格式:selector.value = '赋值内容',举例:
// ID为Text的文本框赋值为“1”
document.getElementById('Text').value = '1';
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有一个onlocal事件啊,用这个事件,加载的时候文本框就有值了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
document.getElementById("text_box_id").innerHTML = "your text";
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<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 = ReadCookie();
</script>
<form name="addform" action="" method="get">
<input type="button" value="查看保存的COOKIES值" onclick="ReadCookie()">
<input type="text" id="txt1" value="" name="mail" onclick="ReadCookie()">
</form>
这样就能把cookie_val 的值赋给下面那个的文本框,直接显示出来
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 = ReadCookie();
</script>
<form name="addform" action="" method="get">
<input type="button" value="查看保存的COOKIES值" onclick="ReadCookie()">
<input type="text" id="txt1" value="" name="mail" onclick="ReadCookie()">
</form>
这样就能把cookie_val 的值赋给下面那个的文本框,直接显示出来
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<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>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询