I have basic code for autocomplete search in index.php:
<script>
$(function() {
$( "#port" ).autocomplete({source: 'search.php'});
}
</script>
My search.php
looks like:
$searchTerm = $_GET['term'];
$query = $db->query("SELECT DISTINCT port FROM reservations WHERE port LIKE '%".$searchTerm."%' ORDER BY port ASC");
while ($row = $query->fetch_assoc()) {
$data[] = $row['port'];
}
echo json_encode($data);
And now I need to compare that value with database row in my index.php
dp.onBeforeEventRender = function(args) {
var start = new DayPilot.Date(args.e.start);
var end = new DayPilot.Date(args.e.end);
var today = new DayPilot.Date().getDatePart();
var now = new DayPilot.Date(); var job = args.e.job;
if (args.e.port == "$_GET['$searchTerm']" && args.e.active == 0){
args.e.backColor = 'green';
}
}
But it is not working. Any ideas?
If you just want to check the value when a search is performed [dataTables 1.10.x]
var table = $('#example').DataTable();
$('#example').on('search.dt', function() {
var value = $('.dataTables_filter input').val();
console.log(value);
if you want to check the value before the search, and be able to cancel the search, you must unbind the default searchbox event and create your own, like this - search only when the user has entered more than 3 characters
$('.dataTables_filter input').unbind().keyup(function() {
var value = $(this).val();
if (value.length>3) {
table.search(value).draw();
}
}); demo -> http://jsfiddle.net/pb0632c3/