Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 30th, 2004, 02:12 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Drop Down/Combo box/List in a Form from DB

Hi guys, this is the first time i am doing any web development. I hope you can help me about this. The problem is bellow:
I have a user table with the fields show bellow
Say tUser(UniqueName, F_Name,L_Name, MI...)

I want to create a data entry form which will contain UniqueNAme fields (along with other fields). I have to get data of the UniqueName from this table (access database) when the form loads in the drop down/list/combo box. I know just simple insert/update and deletes but i have not done this before. Can any body help me how can i do this.
I will appreciate your help
thanks :)

Reply With Quote
  #2 (permalink)  
Old September 30th, 2004, 07:23 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Is UniqueName a text field? If so, it is not unique. There is every possibility the same value may be inserted more than once (unless you do a check on the table before insert - not ideal, there are easier ways to achieve uniqueness)

I would create the table like so:
1..ID = int (set to primary key and auto incriment)
2..UniqueName = varChar (do you need this field?)
3..F_Name = varChar
4..L_Name = varchar

Having a true unique field is very important in most cases. Even if you think you dont need it, incude it anyway. As it is auto incrimenting, there is no need to populate it when inseting and updating.

AnyHow to show the details in a comboBox:
<%
'get records
sql = "SELECT id,UniqueName, F_Name,L_Name FROM tUser;"
'populate record set
set getInfo = conn.execute(sql)
%>

<select name="someName">
 <option name="selectAValue">Select A User From The List</option>
<% if not getInfo.EoF then
      do until getInfo.EoF
         response.write "<option value=" & getInfo(0) & ">" & getInfo(1) & "</option>"
         getInfo.moveNext
      loop
   else
      response.write "<option value=NoValues>No Records Found</option>"
   end if %>
</select>

The above combo box code will produce a list containing the 'ID'[getInfo(0)] field as the value for each item and show the 'UniqueName' [getInfo(1)] as the text string value for selection

Alternativly if you don not wish to create an 'ID' field in your table and wish the value being passed along with the visible text value of each item in the list to be 'UniqueName' :

Change This:
sql = "SELECT id,UniqueName, F_Name,L_Name FROM tUser;"
To This:
sql = "SELECT UniqueName, F_Name,L_Name FROM tUser;"
AND Change This:
response.write "<option value=" & getInfo(0) & ">" & getInfo(1) & "</option>"
To This:
response.write "<option value=" & getInfo(0) & ">" & getInfo(0) & "</option>"

Wind is your friend
Matt
Reply With Quote
  #3 (permalink)  
Old October 1st, 2004, 10:43 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot for your help, I will try this code. Once again i appreciate your help and valuable suggestions.
Azimi:)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
add drop down / combo box for selection mamuco Classic ASP Components 0 May 30th, 2007 06:34 PM
Combo Box Won't Drop Down sjf905 C# 0 January 13th, 2007 12:09 AM
Displaying drop down menus on the top of Combo box karunkumar_g Javascript 3 December 14th, 2005 01:46 PM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM



All times are GMT -4. The time now is 06:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.