0
I am using the Jquery autocomplete and it is working noralmente. But, this populating a type text that contains only one field (txt itself) to fill.
I would like a select to be filled instead of txt.
Somebody help me out?
Follows the code
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http:////code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="style.css">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
var clientes = [
"Fulano",
"Bertanbo"
];
$( "#clientes" ).autocomplete({
source: clientes
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="clientes">clientes: </label>
<input id="clientes">
</div>
</body>
</html>
I’d like to change the
<input id="clientes">
For
<select name="clienteEscolhido">
<option value=""></option>
</select>
jquery autocomplete it was fetus to run on top of text field same, for you use it in combobox I think you are looking for a multiselect with search. Something like this https://select2.github.io/examples.html would that be? or you may be wanting something like this https://jqueryui.com/resources/demos/autocomplete/combobox.html but it is not done on top of a combo but a normal input with a list :D
– Brunno
Good. It’s the following. The combobox (select), has 2 fields. One with the value of the option that brings the id of the Client and a text that bears the name of the client. <option value"idClient">Client Name</option>. This field will be submitted in a form to take the Client id on the other side and display its data! That’s why select needs to be this way!
– Carlos Rocha
Carlos, you can do this directly by autocomplete in the type="text" field even using the key and value.. ai in the auto select complete you arrow the id in an Hidden field to be sent in your form. I will post an example in the answer :D
– Brunno
I don’t quite understand your question. You want to type in
input
same turn aselect
?– Randrade
No, I do, I want to type in the select itself. Select won’t let you type because when you click on the text it opens the combobox. Right, but I wish I could type. The perfect example would be what is on this link. But is there Jquery script saw? There is no way to decrease no? rsrs. https://jqueryui.com/resources/demos/autocomplete/combobox.html
– Carlos Rocha