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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to populate Menu Box

Status
Not open for further replies.
Jan 19, 2003
34
US
How do I go about making the possible values for a menu box in a form dynamic( where I can populate the list with values from the database )?
 
Dreamweaver will hate this - but put this in up above the <head> tags - and modify for your details

<%
set rsModel = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsModel.ActiveConnection = MM_my_STRING
rsModel.Source = &quot;SELECT * FROM myTable ORDER BY someField ASC&quot;
rsModel.CursorType = 0
rsModel.CursorLocation = 2
rsModel.LockType = 3
rsModel.Open()
rsModel_numRows = 0
%>
<%
ModelOpts = &quot;<OPTION></OPTION>&quot; & vbNewLine
While NOT rsModel.EOF
ModelOpts = ModelOpts _
& &quot;<option>&quot; & rsModel(&quot;fldModel&quot;) & &quot;</option>&quot; & vbNewLine
rsModel.MoveNext()
Wend
rsModel.Close
%>


Then where you want the list box to be - put this as the code.

<select name=&quot;txtModel&quot;>
<% =ModelOpts %>
</select>

&quot;Never underestimate the power of determination&quot;

Stuart
 
Nice hand code Schase. But if you just create a recordset to the values you require then insert a menu/dd list select it and you have the option to make a dynamic list from any of the recordsets on your page.

Cheech [Peace][Pipe]
The secret of life is honesty and fair dealing. If you can fake that, you've got it made.
Groucho Marx (1895-1977)
 
lol

to be honest, at this point I only use DW for laying out tables and such. HTML Stuff, i'm handcoding everything now - it gets easy to forget. &quot;Never underestimate the power of determination&quot;

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top