Populating a selectbox with a string

S

shankwheat

I have a selectbox which contains the values below and the user can
customize which option values appear in the selectbox as well as the
order they are in. This customized order is saved in a database for the
user to retrieve later in a string like 'Div3,Div4,Div9,Div1'. My
question is how to I take this string and populate the selectbox only
with the values in the string and in the correct order when the page
loads? Thanks


<select id="from" multiple="multiple" size="10">
<option value="Div1">Div1</option>
<option value="Div2">Div2</option>
<option value="Div3">Div3</option>
<option value="Div4">Div4</option>
<option value="Div5">Div5</option>
<option value="Div6">Div6</option>
<option value="Div7">Div7</option>
<option value="Div8">Div8</option>
<option value="Div9">Div9</option>
<option value="Div10">Div10</option>
</select>

So the user's customized selectbox based on the values saved would be

<select id="to" multiple="multiple" size="10">
<option value="Div3">Div3</option>
<option value="Div4">Div4</option>
<option value="Div9">Div9</option>
<option value="Div1">Div1</option>
</select>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top