Click here to Skip to main content
12,884,415 members (30,706 online)
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 20 Apr 2004

Multiple Selection Listbox with Database Connectivity

, 25 Apr 2004
Rate this:
Please Sign up or sign in to vote.
Creating multiple selection Listbox on the fly.


This article/code snippet illustrates on how to create a multiple listbox on the fly through an ASP document, having the contents/data/items to be selected stored on a table in a database. The files are organized perfectly for your reference.

Using the code

Database connectivity is found at global.asa, either connect through a simple MS Access database or MS SQL Server database.

Sample code:

application("con").open "PROVIDER=MSDATASHAPE;DRIVER=" & _ 
application("con").open "Driver={Microsoft Access Driver (*.mdb)};" _
        & "DBQ=" & Server.MapPath("database/main.mdb")

Dealing with Recordsets for data retrieval is found at utility.asp on <modules>.

Sample code:

Sub CrRst(byref rst, rstctr, strsql)
    set rsCreate = server.CreateObject("adodb.recordset")

    CrRst rst, ctr, <SQL>
   'rst - holds the records/data in array, 
   'e.g. rst(1,2), (1) - indicates the field:(2) - indicates the record
   'ctr - record counter
  '<SQL> - SQL statement

Creating the multiple listbox with items/data returned from a Recordset is found in utility.asp on <modules>.

Sample code:

sub listbox_mul(name, strsql, blank, selected, events, width_in, size_in)
    response.write "<SELECT name='" & name & "' id='" & _
                   name & "'" & events & " size='" & _
                   size_in & "' style='width:" & width_in & "px'>" & crlf

    <%listbox_mul "optFilterOpt", _
       "select ID, ITEM from tblRefItems order by ID" , true, "", "", 100, 10%>

Transferring of listbox items/data functionality is found at listbox_option.js on <includes>.

Sample code:

function SelAll(a, b){
    availableList = document.getElementById(a);

    <input type="button" value=">>" 
      name="addAll" onclick="SelAll('optFilterOpt','optFilterSel')">


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Gymson Viente
Web Developer
Philippines Philippines
Information technology professional capable of managing technology projects from concept to completion with remarkable deadline sensitivity. Six years experience as an information developer builder. Strong analytical and logical skills combined with experience in object-oriented techniques.

You may also be interested in...

Comments and Discussions

Generalhelp ! database connectivty with textbox controls in using C# code Pin
Narashiman.K23-Sep-07 10:47
memberNarashiman.K23-Sep-07 10:47 
GeneralImportant Reminder Pin
logan_stryker19-Jan-07 15:17
memberlogan_stryker19-Jan-07 15:17 
QuestionMultiple list insert to database Pin
hsaleh0727-Dec-05 7:15
memberhsaleh0727-Dec-05 7:15 
GeneralUhm.. Pin
Koundinya22-Apr-04 21:08
memberKoundinya22-Apr-04 21:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170422.1 | Last Updated 26 Apr 2004
Article Copyright 2004 by Gymson Viente
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid