Topic: JS and select box
phoenixschule pro premium priority asked 3 years ago
JS for a select box
document.getElementById('xxx').getElementsByTagName('option')[yyy].selected = true
is working fine with standard - not working with your select (class="select")
any ideas?
br thomas
Michał Duszak staff answered 3 years ago
You can refer to the Select with our getInstance()
method. For example:
https://mdbootstrap.com/snippets/standard/m-duszak/3129292#js-tab-view
For further instructions read our API tab for Select: https://mdbootstrap.com/docs/standard/forms/select/#docsTabsAPI
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 3.7.1
- Device: PC
- Browser: ALL
- OS: WIN10
- Provided sample code: No
- Provided link: No
UNNdev pro premium priority commented 3 years ago
Read the documentation's API / Methods section.
Select.getInstance(document.getElementById('xxx')).setValue(yyyy)
where yyyy is the value you want to set and xxx the ID of the element.