Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

Sponsored Links

Discuss "Creating Dynamic Dropdown Menu!?" in the ASP Development forum.

ASP Development - Learn coding practices and tips to get the best out of your Active Server Pages (ASP). The Classic ASP forum is for ASP/VBScript and ASP/JScript applications.


Closed Thread « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1  
Old March 20th, 2008, 12:26 PM
Barn Newbie
 
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
jarvelous is an unknown quantity at this point
Default Creating Dynamic Dropdown Menu!?

Hi everyone. I am new to ASP and am wanting to create a drop down menu. I have a table in my database called 'members'. I want to show all members in the drop down.

My field names that I need to populate the drop down table with are:

- MemberID (Value to pass)
- MemberName (Option to be displayed)

Can you please tell me how to create a drop down?

Thanks!!
jarvelous
Sponsored Links
  #2  
Old March 20th, 2008, 12:30 PM
BLaaaaaaaaaarche's Avatar
Administrator


 
Join Date: Mar 2008
Posts: 55
Thanks: 10
Thanked 7 Times in 5 Posts
Rep Power: 1
BLaaaaaaaaaarche is on a distinguished road

Awards Showcase
HTML & CSS Classic ASP 
Total Awards: 2

Default

Hey jarvelous, welcome to the DeveloperBarn forums! To create a dynamic drop down menu, you first need to create a recordset to your DB. You can do this like so:

Code:
strSQL = "SELECT MemberID, MemberName FROM members ORDER BY MemberName"
Set objRS = siteConn.Execute(strSQL)
After you have created your recordset, you will want to loop through the recordset:

Code:
response.write "<select name=""Members"">" & vbCrLf
response.write "<option value="""">Select Member</option>"
Do While Not objRS.EOF
	response.write "<option value=""" & objRS("MemberID") & """>" & objRS("MemberID") & "</option>" & vbCrLf
objRS.MoveNext
Loop
response.write "</select>" & vbCrLf
You will also want to make sure you close your connection after your are done. Do so like so:

Code:
objRS.Close
Set objRS = Nothing
Hope this helps. Let us know if you need any additional help.

Comments on this post
jmurrayhead agrees:
jarvelous agrees: thanks!!!!!!!!!!
sbenj69 agrees:
Closed Thread

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic dropdown list with multiple records Rebelle ASP Development 4 April 30th, 2008 05:33 AM
[ASP.Net/VB.Net] VB.Net Dynamic Recursive Menu jmurrayhead Code Samples 0 March 18th, 2008 10:47 AM


All times are GMT -4. The time now is 02:42 PM.



Content Relevant URLs by vBSEO 3.2.0