Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
bsmultiselect: how to get list or array of items picked by the user?

I stumbled upon the bsmultiselect library for a project. The interface looks good but seems like the documentation needs some more work, hence i cannot figure out how to return the list of items selected by the user. I'd appreciate it if someone could give me a hint at least.

here's my code for now:

const instSel = document.getElementById('instrument-select');

let x = new xhr();

x.get("GET", "instruments.json", (rsp) => {
    instr = JSON.parse(rsp)
    for (i in instr) {
        let optGr = document.createElement("optgroup");
        optGr.setAttribute("label", instr[i]["name"]);
        for (x in instr[i]["instruments"]) {
            let opt = document.createElement("option");
            opt.setAttribute('value', instr[i]["instruments"][x]);
            opt.setAttribute('class', 'dropdown-item');
            opt.textContent = instr[i]["instruments"][x];
            optGr.appendChild(opt);
        }
    instSel.appendChild(optGr);
    console.log(optGr);
    }
    bs = dashboardcode.BsMultiSelect("#instrument-select");
    console.log(bs);
});

document.body.addEventListener('dblclick', () => {
    console.log(bs.getPicks()); // this returns the html only
});

Thanks in advance for any help!

Update

Managed to collect the data by using the e.target event.

instSel.onchange = (e) => {
    // loop through all the items
    for (let i = 0; i < e.target.length; i++;) {
        if (e.target[i].selected) { // if the item is selected
            console.log(e.target[i].textContent)
        }
    }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!