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ö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')?:)如何用项目填充列表框?如何将它们保存为数组?