1
I have to create a filter in select to perform a search between multiple select results
<div class="grupo">
<!-- class="borda select2_single form-control comboauto" -->
<select name="id_projeto" id="id_projeto" class="borda select2_single form-control ">
<option value="">Selecione</option>
<?php
foreach (ProjetoModel::retorna(" order by descricao") as $obj) {
?>
<option value="<?php echo $obj->getid() ?>"
<?php echo $obj->getid()==$vObject->getidProjeto()?'selected':'' ?>>
<?php echo $obj->titulo; ?>
</option>
<?php } ?>
</select>
</div>
Return function
public static function retorna($extra='', $vWhere=null) {
$arr=array();
$sql = 'SELECT * FROM projeto where 1=1 ';
$sql .= self::getWhere($vWhere);
$sql .= $extra;
$vResult = Conexao::getInstance()->query($sql);
while($vResult && $obj = $vResult->fetchObject()) {
$arr[] = new ClassProjeto($obj->id, $obj->titulo, $obj->descricao, $obj->id_net, $obj->id_trafo);
}
return $arr;
}
JAVASCRIPT
<script type="text/javascript">
var config = {
'.chosen-select' : {},
'.chosen-select-deselect' : {allow_single_deselect:true},
'.chosen-select-no-single' : {disable_search_threshold:10},
'.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
'.chosen-select-width' : {width:"95%"}
}
for (var selector in config) {
$(selector).chosen(config[selector]);
}
</script>
I couldn’t understand what it was. It would be like breaking folders?
– Willian Coqueiro
Only perform a search inside the Html Select tag.
– alexjosesilva
But the system is in php and
– alexjosesilva
Ta but this search goes where?
– Willian Coqueiro
I could understand there and that you are creating this select dynamically by the consultation made in the bank with the options you have in the bank. From what I reviewed your question, you want these options to come with filter and not all options, and this?
– Willian Coqueiro
In this part here
foreach (ProjetoModel::retorna(" order by descricao")
you’re calling the functionretorna()
with 1 sort parameterorder by descricao
. Find this function and post here I pass you the answer.– Willian Coqueiro
Edited question...
– alexjosesilva
The filter has to be inside the html select tag
– alexjosesilva