Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 15th, 2006, 09:11 AM
bkinney bkinney is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 1 bkinney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 11 sec
Reputation Power: 0
Dropdown mayhem!

Hello all, quick question here...its been boggling my mind and my heads hurting!


I've been coding my own ASP scripts lately, just started...however none of the 3 books I bought cover MSSQL and ASP integration when it comes to creating dropdown lists...most people reading this are probably laughing already and saying "Damn this guy's a noob!" But we all gotta start out somewhere

Anyhow, I've been trying to get something together for almost a week now...I've just about given up totally and I'm just looking for what people would do code wise to create such a thing to help guide me on my way.

Pretty basic...Just a dropdown that reads from a MSSQL server...in which I can point it to a certain ID / table column to get the potential "list" from. Alphabetize that, and then store that selected item to another table / column which is pre-existing.

Any help would be greatly appreciated...Im just looking for a script I follow to help me out a little. Thanks fellas / gals

Reply With Quote
  #2  
Old August 17th, 2006, 07:02 AM
richyrich's Avatar
richyrich richyrich is offline
Contributing User
ASP Free Specialist (4000 - 4499 posts)
 
Join Date: Jun 2004
Location: Somewhere only we know...
Posts: 4,192 richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)richyrich User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 117793 Folding Title: Super Ultimate Folder - Level 1Folding Points: 117793 Folding Title: Super Ultimate Folder - Level 1Folding Points: 117793 Folding Title: Super Ultimate Folder - Level 1Folding Points: 117793 Folding Title: Super Ultimate Folder - Level 1Folding Points: 117793 Folding Title: Super Ultimate Folder - Level 1Folding Points: 117793 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 1 Week 1 Day 17 h 21 m 25 sec
Reputation Power: 1209
This is a simple script to generate a dynamic dropdown. You will need to alter based on your own database.

Code:
<% 'Set connection
set conn=server.createobject("ADODB.Connection")
'Set Recordset
set rs=server.createobject("ADODB.Recordset")
'Open connection
conn.open "Driver={SQL Server};Server=server1;Database=mydb;Uid=sa;Pwd=;" %>

<!-- HTML code -->
<select name="dropdown1" size="1">

<%
'setup sql query
strsql = "SELECT id,description FROM table1"
'open recordset with query
rs.open strsql,conn
'loop through records returned until End of File
do until rs.eof
'write id and description as an option in dropdown
response.write("<option value="""&rs("id")&""">"&rs("description")&"</option>")
'move to next record
rs.movenext
'return to do
loop
%>
<!-- HTML code -->
</select>

<%
'close recordset
rs.close
'close connection
conn.close

'tidy up objects
set rs=nothing
set conn=nothing
%>


To retrieve the value, use:-

request.form("dropdown1")

Hope that helps.
__________________
Policy Check

I'd rather have a full bottle in front of me, than a full frontal lobotomy...

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > Dropdown mayhem!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway