public function loadGameTeams()
{
global $db, $DBPrefix;
$query = "SELECT team_id, teams FROM " . $DBPrefix . "sports ORDER BY teams asc";
$db->direct_query($query);
$this->SETTINGS['sports'] = [];
while ($row = $db->fetch())
{
$this->SETTINGS['sports'][$row['team_id']] = $row['teams'];
}
}
instead of searching for the first letter or number it picks them ramdomly
for example if i start typing china its start and show achilles instead of chi… before it shows china full hope u guys understand.
I get that, but the code you posted doesn’t seem to handle the situation you are describing, that seems to be done in the searchSel() function, which we can’t see. Your query as you show it doesn’t have any selection criteria, so something else must be looking at what you type, and narrowing down the contents of the drop-down.
if (output[i].text.toLowerCase().indexOf(input) != -1 ){
is probably the issue. Your JS code gets what is typed in the text box, then loops through the options contained in your drop-down list. As soon as it finds one that contains the text you’ve typed, it selects it. indexOf in this case works in a similar fashion to strpos()in PHP. If you only want to find a selection that begins with the text, you could look at startsWith() or probably lots of other ways - I don’t know much JavaScript.