I'm Karl and I'm still new to this place and a rookie when it comes to coding. Please bear with me. I'm more into HTML and CSS. I recently found this Live Search tutorial based on AJAX, JQuery and JSON, where the search function reacts instantly from the moment you start typing in the input field. The keyup() command seems to have something to do with this.
$('#search').keyup(function(){
var searchField = $('#search').val();
var myExp = new RegExp(searchField, 'i');
$.getJSON('data.json', function(data){
var output = '<ul class="searchresult">';
$.each(data, function(key, val){
if((val.name.search(myExp) != -1) || (val.bio.search(myExp) != -1)) {
(...)
I'm currently testing this live search on a local server. (Works like a charm.)
I was wondering if it was possible to send user defined queries / search terms by submitting them via the enter key (the conventional way) and/or via a search/submit button instead. I tried replacing the keyup function with submit. Something like on this video for instance. I tried to apply this kind of submitting, which was mentioned in the aforementioned video, but I didn't get it to work accordingly. I even searched various tutorials via Google, many different videos on Youtube, DailyMotion, etc. and even compared many questions here on stackoverflow and other similar sites. I'm most likely missing the forest for the trees.
Any help would be greatly appreciated. Thank you in advance.