Pass search string on datatables on load

jQuery -- Posted on April 14, 2023

Pass search string on datatables on load

              
                <table id="myTable">
  <!-- Table contents go here -->
</table>

<!-- JavaScript code -->
<script>
$(document).ready(function() {
  // Initialize DataTables
  var table = $('#myTable').DataTable();

  // Get the search query from a search input field, for example
  var searchQuery = $('#searchInput').val();

  // Apply the search query to the DataTables search
  table.search(searchQuery).draw();
});
</script>
                  
   
            

Related Posts