Hello,
I have a certain issue with my search engine. Basically the results are not retrived quite well from my database. Let's say that I want to search a certain thing, let's call it Arad. I fill the box with Ar and I should be getting words which start with Ar. However, the script is searching now through the whole word. I enter Ar and I get results this way: Bar, Car, Adversary, Afterward, Alarm. It basically retrieves me words which contain ar but I should be getting words which start with ar.
Here is a snippet:
$(function(){
// The autocomplete feature for the destinations
jQuery('#fromRoute').autocomplete({
source: '/ag/lib/ajax.php?action=getAutoComplete&direction=from&to_val='+encodeURIComponent($('#toRoute').val()),
select: function(a, b){
if(b.item.value=='Nothing found!'){
$(this).val(''); return false;
$('#toRoute').autocomplete('option','source','/ag/lib/ajax.php?action=getAutoComplete&direction=to&from_val='+encodeURIComponent($(this).val()));
}
$(this).val(b.item.value);
$('#toRoute').autocomplete('option','source','/ag/lib/ajax.php?action=getAutoComplete&direction=to&from_val='+encodeURIComponent($(this).val()));
getScheduleTable()
},
response: function(event, ui) {
if((ui.content.length==1) && (ui.content[0].value!='Nothing found!')){
$(this).val(ui.content[0].value);
$(this).autocomplete('close');
$('#toRoute').autocomplete('option','source','/ag/lib/ajax.php?action=getAutoComplete&direction=to&from_val='+encodeURIComponent($(this).val()));
getScheduleTable()
}
}
});
$('#toRoute').autocomplete({
source: '/ag/libs/ajax.php?action=getAutoComplete&direction=to&from_val='+encodeURIComponent($('#fromRoute').val()),
select: function(a, b){
if(b.item.value=='Nothing found!'){
$(this).val(''); return false;
$('#fromRoute').autocomplete('option','source','/ag/lib/ajax.php?action=getAutoComplete&direction=from&to_val='+encodeURIComponent($(this).val()));
}
$(this).val(b.item.value);
$('#fromRoute').autocomplete('option','source','/ag/lib/ajax.php?action=getAutoComplete&direction=from&to_val='+encodeURIComponent($(this).val()));
getScheduleTable()
},
response: function(event, ui) {
if((ui.content.length==1) && (ui.content[0].value!='Nothing found!')){
$(this).val(ui.content[0].value);
$(this).autocomplete('close');
$('#fromRoute').autocomplete('option','source','/ag/lib/ajax.php?action=getAutoComplete&direction=from&to_val='+encodeURIComponent($(this).val()));
getScheduleTable()
}
}
});