Topic: Multiselect Initial Values

Consult-Patriot-Gas5 free asked 3 years ago


Expected behavior

When you specify an initial value attribute in the tag, then on page load the multiselect component should pre-select the corresponding values.

Actual behavior

Nothing appears to be selected after page load.

Resources (screenshots, code snippets etc.)

<select class="select" multiple value="1,3,4,5,7">
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
  <option value="4">Four</option>
  <option value="5">Five</option>
  <option value="6">Six</option>
  <option value="7">Seven</option>
  <option value="8">Eight</option>
</select>
<label class="form-label select-label">Example label</label>

Michał Duszak staff answered 3 years ago


Hello, you have to do it programatically using setValue() method on your Select component. See this snippet:

https://mdbootstrap.com/snippets/standard/m-duszak/3498288#js-tab-view



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: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.1
  • Device: MacOS
  • Browser: Chrome
  • OS: macOS 10.15.7
  • Provided sample code: No
  • Provided link: No