Metro-UI-CSS icon indicating copy to clipboard operation
Metro-UI-CSS copied to clipboard

data-role="input" data-autocomplete example

Open TorakikiSan opened this issue 4 years ago • 4 comments
trafficstars

I am trying to use the autocomplete feature but I can't figure out how to do it.

I have a field defined as

<INPUT id = "MACHINE" name = "machine" class = "input-small" data-role = "input"
             data-validate = "maxlength=100" data-cls-input = "text-bold fg-orange"
             data-autocomplete-url = "/ajax.autocomplete.php" data-autocomplete-url-method = "POST"
             data-label = "Machine" data-cls-label = "fg-black" value = "" />

and in the file ajax.autocomplete.php I execute a query in my db which returns a JSon array of the type

{"mrdo": "Mr. Do!", "pacman": "Pac-Man (Midway)", "xevious": "Xevious (Namco)"}

but it seems I don't know the parameter passed as the argument to search with (MACHINE?).

Also I would like to pass the query to execute a parameter, "Language", but I have not found the way to do it (of course if it is possible to do so) and the query would become

select machine, description
from machines m
where description like '%' || $MACHINE || '%' and exists
    (select 1
     from languages ​​l
     where m.machine = l.machine and '$LANGUAGE' = language);

where $MACHINE is the contents of the field and $LANGUAGE would be the parameter I would like to pass.

can you help me?

TorakikiSan avatar Sep 26 '21 12:09 TorakikiSan

Thanks for opening a new issue. The author has been notified and will review it as soon as possible. For urgent issues and priority support, visit https://xscode.com/olton/Metro-UI-CSS or Patreon

xscode-auto-reply[bot] avatar Sep 26 '21 12:09 xscode-auto-reply[bot]

https://codepen.io/olton/pen/xxOvoLe

olton avatar Oct 27 '21 11:10 olton

you must return array from php code

[
"Ukraine",
"USA",
"Canada",
"Marokko",
"Singapur"
]

olton avatar Oct 27 '21 11:10 olton

I am very happy that you are back and thanks for the reply.

Can I also use a JSON with a "key" too? Example

[
"1": "Ukraine",
"2": "USA",
"3": "Canada",
"4": "Marokko",
"5": "Singapur"
]

TorakikiSan avatar Nov 02 '21 08:11 TorakikiSan