Topic: Change select value programmatically

smachesney free asked 3 years ago


Hi, can you show me with a snippet how to programmatically change the select value. I do it this way:

$(`#actionTableCategory-${id}`).val(value);

and it sometimes work and sometimes doesn't.

If I did is this way as per your website:

const selectEl = document.getElementById(`#actionTableCategory-${id}`)
const select = new mdb.Select(selectEl)
select.setValue('Open')

It duplicates the select ui.

Thank YouSonia


Michał Duszak staff answered 3 years ago


Hello Sonia,

You can look for an instance of this select. I have prepared a snippet for you.

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

Best regards,

Michal


smachesney free commented 3 years ago

Thank you very much Michal



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Resolved

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: 3.2.0
  • Device: desktop
  • Browser: Chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: No