Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Driven Drop-Down menu

Status
Not open for further replies.

Jlok

IS-IT--Management
Mar 28, 2002
23
US
Want to create a database query based on dynamically driven drop-down menus. Query is not the problem, problem is dynamically creating the drop-downs. Access is database source. Using Frontpage I can create the three drop-downs, but cannot have them change without hitting submit. I think I need either a javascript or VBscript to do this.

Can anyone help??

Thanks-
 
I just did this. I found a Java that would do it, but since that cost $$ and I refuse to pay for what I can make, I instead created this in .ASP:

<% FIELD_VARIABLE = &quot;Default Value Here&quot; 'set default value %><%
RESPONSE_VARIABLE = &quot;<SELECT name='FIELD_VARIABLE'><OPTION value=''>Please Select</OPTION>&quot;
sqlwrk = &quot;SELECT DISTINCT [NAME_OF_FIELD] FROM [NAME_OF_TABLE] ORDER BY [NAME_OF_FIELD] ASC&quot;
Set rswrk = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rswrk.Open sqlwrk, conn, 1, 2
If Not rswrk.EOF Then
datawrk = rswrk.GetRows
rowswrk = UBound(datawrk, 2)
For rowcntwrk = 0 To rowswrk
RESPONSE_VARIABLE = RESPONSE_VARIABLE & &quot;<OPTION value='&quot; & datawrk(0, rowcntwrk) & &quot;'&quot;
If datawrk(0, rowcntwrk) = FIELD_VARIABLE Then
RESPONSE_VARIABLE = RESPONSE_VARIABLE & &quot; selected&quot;
End If
RESPONSE_VARIABLE = RESPONSE_VARIABLE & &quot;>&quot; & datawrk(0, rowcntwrk) & &quot;</option>&quot;
Next
End If
rswrk.Close
Set rswrk = Nothing
response.write RESPONSE_VARIABLE
%>

NAME_OF_TABLE = The name of the table in your database

NAME_OF_FIELD = The name of the field in that table

FIELD_VARIABLE = The variable you assigned as the field name
Example: x_Field5 = Request.Form(&quot;x_Field5&quot;)

RESPONSE_VARIABLE = The variable you assign for this resulting list
Example: x_Field5List = Request.Form(&quot;x_Field5List&quot;)

The above results in a drop-down box that populates based on a particular field in a particular table. In my case I also I added a separate page in which a user can update that table and the resulting drop-down box shows their additions/deletions/changes.

Dave B [idea]
Flashspot.com
 
Oops! I should have said
Example: x_Field5List = &quot;x_Field5List&quot;

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top