select mutiple items from listbox
<p>I have a string as</p>

<pre><code>var selected_values = '1#2#3#4#5';
</code></pre>

<p>Now these are all values for &lt;option&gt;, which are separated by # (so final selected values would be 1 2 3 4 5), I need to select only those "options" whose value is mentioned in above string</p>

<p>How can I achieve this?
1. I need to split string
2. select only those options whose values are mentioned</p>

<p>For single value I am using following code</p>

<pre><code>        var selObj = document.getElementById('list1');
        len = selObj.length;
        selected_value = '1';

        for (i = 0; i &lt; len; i++) {
            if (selObj[i].value == selected_value) {
                selObj[i].selected = true;
            }
        }
</code></pre>
