1
我目前將一個值從search.php
傳遞到filtering.php
。我正在使用$_GET
來完成此操作。在filtering.php
頁面中,我有一個表格,可根據輸入文本框中鍵入的單詞自動過濾。我在URL中傳遞值:http://holaweblearning.co.nf/php_learning/filtering.php?key=Dragoo
。然後從URL獲取值並將其放置在輸入文本框中。但是除非我點擊文本框然後按一個鍵,否則沒有任何東西會被過濾掉。如何將值傳遞給filtering.php
頁面並根據單詞獲取結果? DEMO將值從一個頁面傳遞到另一個頁面,並使用值來過濾表格
我使用footable filtering method
的search.php
<div>
<input type="text" class="search" placeholder="Type 'Dragoo' ">
</div>
<div>
<a href="#" class="search_word">Search</a>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$('.search').bind('change keyup', function() {
var dInput = this.value;
console.log(dInput);
url='http://holaweblearning.co.nf/php_learning/filtering.php?key='+dInput;
$('.search_word').attr('href', url);
});
</script>
filtering.php
<?php
$keyword = $_GET['key'];
?>
Search: <input id="filter" type="text" value="<?php echo $keyword; ?>"/>
是的!這樣可行。我讓它變得更加複雜,但最終它很簡單。 –