javascript - It only shows the latest data? -


in case, put 1 2 3 in each input , shows number 3. how can fix it? i'm sorry if it's stupid question don't know.

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); } 

you rewrote document.cookie 4 times new value each time.

if you'd combine data 4 vars uses code like:

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);  }


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -