Valerie Meunier

Valerie Meunier

  • 1.5k
  • 693
  • 64.4k

how to pass two cookies together to another html-page?

Nov 17 2022 10:30 PM


I'm trying to pass firstname and name from a html page to another html page (without using server code like php or using cookies. This works partially because i get the firstname in the first input of the page action.html but also in the second input. How can i get the name in the second input in action.html?

first page:
<form action="action.html">
        <input type="text" id="vn" autofocus ><br>
        <input type="text" id="an"><br><br>
        <input type="submit" onclick="MakeCookie()">
    <script type="text/javascript">
        function MakeCookie()
            var vn = document.getElementById("vn").value;
            var an = document.getElementById("an").value;
            document.cookie = an;vn;

 <input id="vn" type="text" />
 <input id="an" type="text" />
 <script type="text/javascript">
   cc = document.cookie.split(";");
   document.getElementById("vn").value = cc;
   document.getElementById("an").value = cc;

Answers (2)