나는 이력 검색 기능을 연구 중이다.목록 상자에서 로컬 저장소 사용
텍스트 상자에서 값을 저장하는 작업 코드를 얻을 수 있었지만 목록 상자에 값을로드하는 방법을 모르겠습니다.
클릭 할 수있는 항목이있는 목록 상자를 사용하여 이전 검색 값을 클릭하고 해당 값을 텍스트 상자에서로드 할 수 있습니다.
<!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>
그리고 로컬 저장 기능을 처리하는 j.js :
여기 내 코드입니다.
$(function() {
$("#submit").click(function() {
var txtSearch = $("#txtSearch").val();
localStorage.setItem('searchvalue',txtSearch);
});
});
그리고 포스트 검색 요청
<?php
$txtSearch = $_REQUEST['txtSearch'];
header('Location: '.'https://mywebsite.com/se/editor/order_info.php?webshop=23946&ordernr='.$txtSearch);
?>
내가 어떻게 이것을 달성 할 수를 처리하는 내 test.php 마지막?
감사합니다. JS로
localStorage.getItem ('searchvalue') 배열에 저장합니다? :) –