我目前正在将一个值从 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
搜索.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; ?>"/>
最佳答案
您可以查看事件监听器并得出结论:“keyup”事件负责填充该字段。页面加载时执行类似以下操作:
$('input#filter').trigger('keyup')
关于javascript - 将值从一页传递到另一页并使用值来过滤表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24439564/