Default select option

Topic: Default select option

parson pro premium asked 2 years ago


I want to use the value of a select dropdown as a filter for a table. Using the snippet linked the select loads with the first option selected. Apart from creating a disabled option selected by default is it possible to load the select dropdown without anything selected?

<option value="" disabled selected>Please select an option</option>

Additionally, when the dropdown is created with a data-mdb-clear-button="true" and the selection is cleared it is still returning the first option as it's selected value. This should be null as nothing is selected.

parson pro premium commented 2 years ago

Update - The values was an error on my part. The select box returns values in a htmlCollection called selectedOptions. I was trying to use value.

somboo commented a year ago

Is there documentation of the htmlCollection you can point me to? I've been trying to figure out how to get the selected values from the mdb Select since using jQuery or javascript methods don't seem to do it.

Grzegorz Bujański staff answered a year ago

Note that the default select works like this - it shows the first option checked if no value is set. We don't want to change the default behavior, so the first option will always be selected if value is not set.

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: 3.0.0
  • Device: PC
  • Browser: Firefox
  • OS: Windows
  • Provided sample code: No
  • Provided link: Yes