0

I've go a multiselect:

<select id="select1" multiple> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> 

and javascript object:

{ 0: {id: 1, name: test1} 1: {id: 3, name: test3} 2: {id: 5, name: test5} } 

How to make options "selected" and change value of select using ids from javascript array?

Maybe there is some simple JS function for that? I coded that: but this was a big bunch of code...maybe somebody knows how to do it simple way?

2
  • 1
    "and javascript object:" - Is this really an object? And if so, then why? That should be an array... Commented Dec 22, 2021 at 14:56
  • 1
    There's no "default" JS function to do this. Commented Dec 22, 2021 at 14:57

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.