html dropdown treatment for many options

Asked

Viewed 138 times

1

I have a dropdown that is fed in PHP by consulting an Oracle database. It is working normally, but the amount it returns is 15,000 records and each record is an option in the dropdown. It makes the same slow and ends up being useless like this.

Simplified example:

<select class="form-control select2" name="classificacao_fiscal">
   <option value=""> Selecione uma classificação fiscal </option>
   <option value="1">Classificação 1</option>
   <option value="2">Classificação 2</option>
   <option value="3">Classificação 3</option>
   <option value="4">Classificação 4</option>
   <option value="5">Classificação 5</option>
   ...
   <option value="14999">Classificação 14999</option>
   <option value="15000">Classificação 15000</option>
</select>

Is there any other way to do this? There is some component capable of "paging", IE, as I’m rolling the dropdown, it will bring the next records?

I’m using as a component Select2, where it has a searchbox for the user to filter these records.

  • 1

    I think using select is not very good in this case, I suggest creating some other solution to select the classification, something like a modal. But if you need to use select you could maybe use the optgroup and group items by quantity ex: Each group keep 1000 records. Even so I still think that select is not a good option. (Edit: I just remembered that optgroup will not change anything with the default select browser...)

  • 1

    Do an input where the user will enter only the number.

  • If it’s all repetitive and only changes the number, it doesn’t make much sense to create a dropdown.

  • really, in case it’s just numbers you can input the number type and set a min and max for it.

  • 1

    I use this component Jquery Autocomplete with Ajax

  • I’m sorry if my question is unclear, but the options are not just going to be numbers, they are registrable and each is different from the other. Example of options: <option value="212748"> Classificação de Nota X </option>&#xA;<option value="487891"> Classificação de SD </option> The user will not know the number, only the description that was registered.

  • @Alex I ended up changing the component to what you gave me, eventually solved. I was just curious how I could keep the dropdown, if there would be another alternative, but anyway, puts as a response to give as completed, please thank you.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.