Topic: Default select option

parson premium asked 3 years ago


Hi

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.

https://mdbootstrap.com/snippets/standard/parson/2838450


parson premium commented 3 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 free commented 3 years 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 3 years 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.

FREE CONSULTATION

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

Status

Answered

Specification of the issue

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: 3.0.0
  • Device: PC
  • Browser: Firefox
  • OS: Windows
  • Provided sample code: Yes
  • Provided link: Yes