| | |
|
Active Server Pages help tutorial how to ASP Help ASP Tutorials ASP Programming ASP Code - ASP Free CJWSoft ASPProtect ASPBanner ASPClassifieds
(Advanced)
(Components)
(Database)
(General)
(Vbscript)

|
|
Subject: |
Re: Dropdown select box |
From: |
Harlan |
Date: |
3/15/1999 8:49:14 AM |
IP: |
206.222.20.2 |
I think they go over this somewhere else, but I'll post the code (cuz, I have a projected opened that does it). As for the board, its not mine, but adding what ya asked for wouldn't be hard. ;)
code here..
'----------------------------------------------------------------
' Name: CreateSelect
'----------------------------------------------------------------
' Purpose: Create Select list
' from sql statement
'----------------------------------------------------------------
' Takes:
' selectName the name of the
' select list
' sqlString the sql query to
' create the select.
' optionValue, the field name
' to be used as the options
' value= field
' optionViewable, the field name
' to be used as the options
' viewable field
'----------------------------------------------------------------
' Returns: Nothing
'----------------------------------------------------------------
Sub CreateSelect(selectName, sqlString, optionValue, optionViewable)
'open the database
DBOpen
'open the query
Set rsSelect = DB.Execute(sqlString)
'write out the select
%><SELECT Name='<%=selectName%>'><%
If rsSelect.EOF and rsSelect.BOF then
'what to do if we don't find any.
%><Option Value='-1'>None Found<%
Else
'and if there are some
Do While Not rsSelect.EOF
If rsSelect(optionValue) = Session("select" & selectName) Then
'if it was last selected, select it again.
%><Option Value='<%=rsSelect(optionValue)%>' selected><%=rsSelect(optionViewable)%><%
Else
'if not, don't select it
%><Option Value='<%=rsSelect(optionValue)%>'><%=rsSelect(optionViewable)%><%
End If
'move to the next record
rsSelect.MoveNext
'go threw the loop again
Loop
End If
'close the database
DBClose
'write out the end of the select
%></SELECT><%
End Sub
this is one of the functions in my standard library of includes.. here is how its used:
'dimension variables
dim sqlType
'create query string
sqlType = "Select catagory,typeid from catagories order by catagory"
'create the select list, using functions.inc createSelect
Call CreateSelect("type",sqlType,"typeID","catagory")%>
|
Previous Message
Follow Up - Re: Dropdown select box - Bruce 3/16/1999 2:41:26 AM
|
|

|
|
|
|