簡體   English   中英

將值從一頁傳遞到另一頁並使用值過濾表

[英]Passing values from one page to another and using value to filter table

目前我正在從一個傳遞價值search.phpfiltering.php 我正在使用$_GET來完成。 filtering.php頁面中,我有一個表,該表根據輸入文本框中鍵入的單詞自動過濾。 我正在URL中傳遞值,例如: http://holaweblearning.co.nf/php_learning/filtering.php?key=Dragoo : http://holaweblearning.co.nf/php_learning/filtering.php?key=Dragoo 然后,采用URL中的值並將其放置在輸入文本框中。 但是除非我單擊文本框並按一個鍵,否則不會過濾任何內容。 如何將一個值傳遞給filtering.php頁面並根據單詞獲取結果? DEMO

我正在使用可過濾的方法

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; ?>"/>

您可以查看事件偵聽器,並得出結論,“ keyup”事件負責填充該字段。 頁面加載時執行以下操作:

$('input#filter').trigger('keyup')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM