【问题标题】:Passing values from one page to another and using value to filter table将值从一页传递到另一页并使用值过滤表
【发布时间】:2014-08-17 20:09:44
【问题描述】:

我目前正在将一个值从search.php 传递给filtering.php。我正在使用$_GET 来实现这一点。在filtering.php 页面中,我有一个表格,可以根据输入文本框中输入的单词进行自动过滤。我在 URL 中传递值,例如:http://holaweblearning.co.nf/php_learning/filtering.php?key=Dragoo。然后获取 URL 中的值并将其放入输入文本框中。但是除非我单击文本框并按一个键,否则不会过滤任何内容。如何将值传递给filtering.php 页面并根据单词获取结果? DEMO

我正在使用脚注filtering method

搜索.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>

过滤.php

<?php
    $keyword = $_GET['key'];
 ?>

Search: <input id="filter" type="text" value="<?php echo $keyword; ?>"/>

【问题讨论】:

    标签: javascript jquery footable


    【解决方案1】:

    您可以查看事件侦听器并得出结论,“keyup”事件负责填充该字段。页面加载时执行以下操作:

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

    【讨论】:

    • 是的!这样可行。我让它变得更复杂,但最终它很简单。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-01
    • 1970-01-01
    • 2013-10-28
    • 2018-12-01
    • 2013-05-30
    • 1970-01-01
    相关资源
    最近更新 更多