0

I am using a data table script found at 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. 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!

Joshua Olds
  • 177
  • 3
  • 11
  • Is there a specific reason for posting this question [twice](http://stackoverflow.com/questions/12866017/javascript-simulate-pressing-enter-in-input-box)? – BudwiseЯ Oct 13 '12 at 02:13

1 Answers1

1

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.

Hopes it clarifies your doubt. If any problem comes comment it.

Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
  • You doesn't even need Ajax, as i saw on the link it's searching on a html output table, so if you have the info in an array or json object before putting them into a table you can just search in those array/objects – aleation Oct 13 '12 at 09:47
  • The search function already works as from the example. The issue is I made some links to common search terms, when they click the link it takes them to a page with the data table and the search term already written to the input box. The issue is it doesnt actually search the table until the user types an additional letter (or deletes) or presses enter inside the search bar. Im trying to get it to do it automatically for them... – Joshua Olds Oct 13 '12 at 15:23