By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,867 Members | 1,981 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,867 IT Pros & Developers. It's quick & easy.

how to retain selected items of multiple select after post

P: 2
I have a database driven multiple select which I generate by the code below.

Expand|Select|Wrap|Line Numbers
  1. <select name="catID" size="10" multiple="multiple" id="catID">
  3. <option value="<%=rs("ID")%>" ><%=rs("catname")%></option>
  4. </select>

How can I retain the selected items after posting the page?

Jul 18 '12 #1
Share this Question
Share on Google+
1 Reply

P: 2
I sorted it and I want to share the solution so it may be useful for someone in the future.

Expand|Select|Wrap|Line Numbers
  1. Function IsSelected(id,qstring)
  2.             myarray = split(qstring,", ")
  3.             IsSelected = ""
  4.             for i=0 to uBound(myArray)    
  6.                 If int(id) = int(myarray(i)) Then
  7.                     IsSelected = "selected=""selected"""
  8.                     'Exit Function
  9.                     End If    

Expand|Select|Wrap|Line Numbers
  1. <select name="catID" size="10" multiple="multiple" id="catID">
  3. <option style="background-color:#e6e6e6;" value="<%=rsCat("ID")%>"  <%=IsSelected(rscat("ID"),Request.QueryString("catID"))%>><%=rsCat("catname")%></option>
  4. </select>    
Jul 18 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.