Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: How to set the multiselect's value by js?

herrshi premium asked 5 years ago


Expected behavior

when I have do some select in a multiSelect, I save the value to the db, then I close the tab. Next time I open the multiselect, I want some options in the select remain checked.

Actual behavior

Resources (screenshots, code snippets etc.)

I tried like this (worked in a normal select):

$("#someMultiSelect")
.find("option:contains('" + savedValue + "')")
.attr("selected", "selected");

It doesn't work.


MDBootstrap staff answered 5 years ago


Hi herrshi,

I created snippet with example for you: https://mdbootstrap.com/snippets/jquery/pjoter-2-0/958370

If you need additional help I am here for you.

Best Regards, Piotr



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 jQuery
  • MDB Version: 4.8.5
  • Device: pc
  • Browser: chrome
  • OS: windows 10
  • Provided sample code: No
  • Provided link: No