简体   繁体   English

在页面加载时提交数据表搜索表单

[英]Submit data table search form on page load

I am using a data table script found at http://datatables.net/ref 我正在使用http://datatables.net/ref上的数据表脚本

This is the code I am using so far to just add the value to the search field. 到目前为止,这是我仅用于将值添加到搜索字段中的代码。 However it doesnt actually search the data table unless the user presses enter or adds/deletes a character in the search box. 但是,除非用户在搜索框中按Enter或添加/删除字符,否则它实际上不会搜索数据表。 Refer to the link for a demo of exactly what it does, just type something in their search box. 请参阅该链接以获取确切演示的示例,只需在搜索框中输入内容即可。

<script type="text/javascript">
       window.onload = (function() {
           document.getElementById('search').value = " <?php echo $st;?>";
</script>

Thanks in advance for your help! 在此先感谢您的帮助!

As far as I understand your question. 据我了解你的问题。 You want when user enters any character or word , it should display all matching result in table format. 您想要在用户输入任何字符或单词时以表格格式显示所有匹配的结果。

So for this you have to use onkeyup event of this search box and call ajax function for sending the input and displaying the result. 因此,为此,您必须使用此搜索框的onkeyup事件并调用ajax函数来发送输入并显示结果。

Hopes it clarifies your doubt. 希望它能澄清您的疑问。 If any problem comes comment it. 如果有任何问题,请对其进行评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM