Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove dup entries in a list box

Status
Not open for further replies.

Kendel

Programmer
Joined
Apr 24, 2002
Messages
1,512
Location
US
Hi there,

Can someone please show me how to remove duplicate entries in a listbox before I save them to the DB.

Many Thanks.

-kendel
 
Is it safe to assume that your populating the list box from a database?

if so

use select Distinct * from table....
 
Yes, the list is populated from DB. But user can also add more items to this list from another list.

thanks.
 
Yes I did use 2 different 'distinct select's to populate items into 2 lists. Then I let users move items from 1 list to another. When they done with movinf items around, there might be some dups in the lists. I want to remove the first before saving.
 
the best thing would be to check it with javascript onSubmit, I can workaround on a function for you if you wish
 
Thanks sharedword. Before submitting the page, I want to call a script function to remove the dup in the box but I don't know how write it. If you know how, please kindly show me.

Many thanks.

-kendel
 
please first show me the an example of your select bow where you need the function to be done
 
Something like this:
Code:
<form name="form1" method="post" action="me.asp">
<Table>
   <tr>
     <td>
        <Select name="List2" size="5" mutiple>
            <%While not RsData.EOF%>
            <option value="<%=RS("id")%>">
                 <%=Rs("Name")%>
            </option>
            <% RS.MoveNext
               Loop
             %>
         </select>
      </td>
      <td><input type="button" value="Save" onclick="RemoveDupe();">
    </tr>
</table>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top