Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 11th, 2004, 07:29 AM
Authorized User
 
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default multiple select--Urgent

Hi,
I am retriving records from SQLDB and populating the datas in Mutiple select box My doubt is say for example i am retiving 15 records from table out 15 records from table out of 15 records i want 5 to 6 records automatically selected in select list box can any one help in this regard


 
Old May 12th, 2004, 06:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

What is the frontend you use?

-Vijay G
 
Old May 12th, 2004, 06:43 AM
Authorized User
 
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ASP

 
Old May 12th, 2004, 07:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

As you say you wanted to select multipls values be default while populating the SELECT box.

Do you have those 5/6 selectable data values prior to pulling data from DATABASE?

If so, assuming it to be in an array. While populating from the database, you would be running through a while loop untill EOF of RECORDSET, within that loop put a FOR loop based on LBOUND to UBOUND of the ARRAY that has values to be selected by default and set the <option> tags SELECTED attribute when the CURRENT record value is EQUAL to the CURRENT subset of the ARRAY.

I can give you a PSEUDOCODE/algorithm here.

<Select> tag...
<%
While NOT RS.EOF
   sFlag=""
   For i=Lbound(ARR) to Ubound(ARR)
     If LCASE(ARR(i))=LCASE(RS("DATAFIELD")) then
          sFalg="Selected"
          BREAK THE LOOP HERE
     End If
   Next
     Response.write "<option ....Value='" & RS("DATAFIELD") & "' " & sFlag & ">" & RS("DATAFIELD") & "</Option>"
   RS.movenext()
Wend
%>
</Select> End Tag...

Something like this should do the trick for you.
Hope that helps.
Cheers!

-Vijay G





Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent :Multiple checkbox value ivanlaw Classic ASP Databases 0 August 11th, 2008 03:54 AM
Multiple select box vinikz Java Databases 1 September 4th, 2007 07:21 AM
select value in listbox please help urgent akssmv C# 2005 1 July 9th, 2007 06:07 AM
Select multiple ranges.... Mats Excel VBA 2 June 9th, 2005 08:01 AM
URGENT: automate - OPEN A FILE DIALOG BOX,SELECT chichi120976 Excel VBA 1 December 13th, 2003 05:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.