Very large select box content

1

I have a selectbox <select> HTML that has a very large content, there are more than 1000 records that should be loaded, but in performance issues I believe it is getting bad.

I would like some solution in javascript, jquery or angular, that solves my performance problem when loading the data in that selectbox.

I currently load my selectbox like this:

<select id="id_empresa" class="form-control">                                   
    <option value="0">Todas</option>
    <?php foreach( $empresas as $empresa ): ?>
        <option value="<?=$empresa[ "id_empresa" ];?>"><?=$empresa[ "nome" ];?></option>
    <?php endforeach; ?>    
</select>
    
asked by anonymous 03.11.2016 / 15:25

1 answer

2

Generic response: If you have a large amount of records, the select (or similar) element may not really be a suitable solution. Try something that allows the user to perform some sort of filtering by populating the select via AJAX, preferably limiting the maximum number of records that can be returned.

Take a look at this list: 13 jQuery SelectBox / Drop-down Plugins ; give preference to those with AJAX support, to better limit the amount of records that need to be loaded.

    
03.11.2016 / 15:50