Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在列表框上使用本地存储_Javascript_Jquery_Html_Local Storage - Fatal编程技术网

Javascript 在列表框上使用本地存储

Javascript 在列表框上使用本地存储,javascript,jquery,html,local-storage,Javascript,Jquery,Html,Local Storage,我正在开发历史搜索功能 $(function () { $("#submit").click(function () { var txtSearch = $("#txtSearch").val(); localStorage.setItem('searchvalue',txtSearch); }); }); 我已经设法获得了一个工作代码来保存文本框中的值,但我不知道如何将它们加载到列表框中 我想要一个带有可点击项目的列表框,这样我就可以点击上一

我正在开发历史搜索功能

$(function () {

    $("#submit").click(function () {
        var txtSearch = $("#txtSearch").val();
        localStorage.setItem('searchvalue',txtSearch);
    });
});
我已经设法获得了一个工作代码来保存文本框中的值,但我不知道如何将它们加载到列表框中

我想要一个带有可点击项目的列表框,这样我就可以点击上一个搜索值并像从文本框一样加载该值

这是我的密码:

<!doctype html>
<html lang="en">
   <head>
      <title>Test</title>
      <meta charset="utf-8>
         <link rel="stylesheet" type="text/css" href="test.css">
      <script src="jquery.js"></script>
      <script src="j.js"></script>
   </head>
   <body>
    <center>
      <table>
         <tr>
            <td style="text-align: center">
               <font size="22">S&ouml;k order</font>
            </td>
         </tr>
         <tr>
            <td>
               <form action="test.php" method="post"> 
                  <input style="font-size: 44pt; text-align: center" size="9" type="text" name="txtSearch" id="txtSearch"/> 
                  <input type="submit" id="submit" value="submit">
               </form>
            </td>
         </tr>
      </table>
      </center>
   </body>
</html>
最后是处理post搜索请求的test.php

<?php
$txtSearch = $_REQUEST['txtSearch']; 
header('Location: '.'https://mywebsite.com/se/editor/order_info.php?webshop=23946&ordernr='.$txtSearch);
?>

我怎样才能做到这一点

谢谢。

通过js,您可以

window.location = "https://mywebsite.com/se/editor/order_info.php?webshop=23946&ordernr="+localStorage.getItem('searchvalue');
保存在列表框或任何其他

document.getElementById("id").value=localStorage.getItem('searchvalue');
保存在数组中

var a = [];
a[0]=localStorage.getItem('searchvalue');

localStorage.getItem('searchvalue')?:)如何用项目填充列表框?如何将它们保存为数组?