在这种情况下,我在每个输入中输入1 2 3,它只显示3号。我该如何解决?如果这是一个愚蠢的问题,我很抱歉,但我真的不知道。
function WriteCookie()
{
cookievalue= document.myform.firstname.value+";";
cookievalue1= document.myform.memory.value+";";
cookievalue2= document.myform.half.value+";";
cookievalue3= document.myform.lose.value+";";
document.cookie=cookievalue;
document.cookie=cookievalue1;
document.cookie=cookievalue2;
document.cookie=cookievalue3;
alert(document.cookie);
}
答案 0 :(得分:1)
每次用新值重写document.cookie 4次。
如果您想要合并来自所有4个变量的数据,请使用以下代码:
function WriteCookie()
{
var cookievalue = document.myform.firstname.value+";";
var cookievalue1 = document.myform.memory.value+";";
var cookievalue2 = document.myform.half.value+";";
var cookievalue3 = document.myform.lose.value+";";
cookievalue = cookievalue + cookievalue1 + cookievalue2 + cookievalue3;
document.cookie = cookievalue;
alert(document.cookie);
}