$(document).ready(function() { $('.search-bar').on('keyup', function() { var query = $('.search-bar').val(); var filter = 0; if($('#type').is(':checked')) filter += 1; if($('#partno').is(':checked')) filter += 2 + 4 + 8; if($('#description').is(':checked')) filter += 16; if($('#notes').is(':checked')) filter += 32; $.getJSON('http://127.0.0.1:5000/query/' + filter + '/' + query, function(data) { var newResults = '
'; for(var i = 0; i < data.length; i++) { // Create new view for results newResults += '
'; newResults += '
'; if (data[i].block != null) newResults += data[i].block; newResults += '
'; newResults += '
'; if (data[i].type != null) newResults += data[i].type; newResults += '
'; newResults += '
'; if (data[i].partno != null) newResults += data[i].partno; newResults += '
'; newResults += '
'; if (data[i].description != null) newResults += data[i].description; newResults += '
'; newResults += '
'; if (data[i].notes != null) newResults += '
' + data[i].notes + '
'; //newResults += data[i].notes; newResults += '
'; newResults += '
'; if (data[i].datasheet != null) newResults += ''; newResults += '
'; newResults += '
'; } newResults += '
'; $('.results').replaceWith(newResults); }).fail(function() { console.log( "failed" ); }); }); });