在javascript中将数据从一个传递到另一个

在javascript中将数据从一个传递到另一个,javascript,html,Javascript,Html,我有两个HTML页面:firstpage.HTML和secondpage.HTML。在firstpage.html中,有一个表单- firstpage.html: <!DOCTYPE html> <html> <head> <title>Form Filling</title> </head> <body> <form action="secondpage.html" method="GET"&g

我有两个HTML页面:firstpage.HTML和secondpage.HTML。在firstpage.html中,有一个表单- firstpage.html:

<!DOCTYPE html>
<html>
<head>
<title>Form Filling</title>
</head>
<body>
     <form action="secondpage.html" method="GET">
Enter Serial Number: <input type="number" name="serialNumber" />
                     <input type="submit" value="Submit" />
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
     <title>Display</title>
</head>
<body>
<form name="selva" action="thirdpage.html">
  <input type="hidden" name="kumar">
</form>
<script type="text/javascript">
    var locate=window.location;
    document.selva.kumar.value=locate;
    var text=document.selva.kumar.value;
      function pass(str) 
      {
        point=str.lastIndexOf('=');
        return(str.substring(point+1,str.length));
      }
document.write("Serial Number" + pass(text));
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
   <title>Repeating</title>
</head>
<body>
<form method="link">
    Enter Serial Number2: <input type="number" name="burns" />
                         <input type="submit" value="Submit" />
</form>
</body>
</html>
第一页数据被发送到secondpage.html。我想在secondpage.html中显示和使用表单数据序列号- secondpage.html:

<!DOCTYPE html>
<html>
<head>
<title>Form Filling</title>
</head>
<body>
     <form action="secondpage.html" method="GET">
Enter Serial Number: <input type="number" name="serialNumber" />
                     <input type="submit" value="Submit" />
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
     <title>Display</title>
</head>
<body>
<form name="selva" action="thirdpage.html">
  <input type="hidden" name="kumar">
</form>
<script type="text/javascript">
    var locate=window.location;
    document.selva.kumar.value=locate;
    var text=document.selva.kumar.value;
      function pass(str) 
      {
        point=str.lastIndexOf('=');
        return(str.substring(point+1,str.length));
      }
document.write("Serial Number" + pass(text));
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
   <title>Repeating</title>
</head>
<body>
<form method="link">
    Enter Serial Number2: <input type="number" name="burns" />
                         <input type="submit" value="Submit" />
</form>
</body>
</html>
现在我可以将serialNumber变量从firstpage.html传递到secondpage.html,这样secondpage.html中的上述代码将显示序列号,我希望在第三页输入相同的序列号- thirdpage.html:

<!DOCTYPE html>
<html>
<head>
<title>Form Filling</title>
</head>
<body>
     <form action="secondpage.html" method="GET">
Enter Serial Number: <input type="number" name="serialNumber" />
                     <input type="submit" value="Submit" />
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
     <title>Display</title>
</head>
<body>
<form name="selva" action="thirdpage.html">
  <input type="hidden" name="kumar">
</form>
<script type="text/javascript">
    var locate=window.location;
    document.selva.kumar.value=locate;
    var text=document.selva.kumar.value;
      function pass(str) 
      {
        point=str.lastIndexOf('=');
        return(str.substring(point+1,str.length));
      }
document.write("Serial Number" + pass(text));
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
   <title>Repeating</title>
</head>
<body>
<form method="link">
    Enter Serial Number2: <input type="number" name="burns" />
                         <input type="submit" value="Submit" />
</form>
</body>
</html>

请告诉我如何在所有这些页面中打印数据?

我能找到的最简单的方法是,将所有三个页面写入一个html文件,并根据条件显示它们。这样,您就不需要使用本地存储

另一种方法是使用查询参数。你可以简单地学习如何使用它们。下面是指向简单javascript处理的查询参数插件的链接:


您可以将序列号作为查询参数传递给另一个html。如果您对如何使用此方法感到困惑,请告诉我,我会详细告诉您。

您是否尝试使用本地存储?否,您能否说明如何使用本地存储如果您只想使用HTML,则可以使用GET请求传递值。如果您打算在网页上使用php,那么会话变量会为您冷库此值为什么使用本地存储?对于简单数据。您想在第二页的何处显示序列号?