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 August 25th, 2004, 06:24 PM
Registered User
 
Join Date: Aug 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create drop down list from SQL DB

I am trying to get values for a drop down list from an SQL database. How do I do this in ASP / vbscript.

My table called 'docmedium' looks like this:

ID Desc
-- ----
1 VHS
2 DVD
3 CD-ROM
4 HDD

I want the Desc values to appear in the drop down list.

Secondly when I save the values in the form back to my master table 'Documents' I want to save the ID and not the Desc. How do I do this.

Cass
 
Old August 25th, 2004, 09:01 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default


You can do using,


strId="<select name='selID'>"
while not rs.eof
  strId=strId & "<option value='" & rs("id") & "'>" & rs("desc") & "</option>"
  rs.movenext
wend
strId=strId & "</select>"


when you submit the form the select control value (ID in this case) is passed. And the user can see desc only.



 
Old August 26th, 2004, 10:49 PM
Registered User
 
Join Date: Aug 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks You Rajanikrishna. That worked great!:D

Cass





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to search db for all triggers and list SQL tcarnahan SQL Server 2000 1 September 1st, 2008 10:42 AM
Create a drop down list using database values erinrox JSP Basics 1 September 4th, 2007 06:59 AM
how to create XML from SQL DB with XSD. sasidhar79 XML 0 July 22nd, 2005 05:55 PM
Retrive values to Drop down list from DB when Back choudhmh Pro VB.NET 2002/2003 0 January 12th, 2005 10:44 AM
Drop Down/Combo box/List in a Form from DB mazimi Classic ASP Basics 2 October 1st, 2004 10:43 AM





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