Dynamic pulldown using DIW

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

With the help of the forum, I have a pulldown in an
edit.asp page working so I can select different project
types instead of using the normal text field.

My next question is how can the pulldown work coming from
the database. Currently I have this code in my edit.asp
page:

<select size="1" name="projType">
<option selected value="<%=fp_rs("projType")%>"><%=fp_rs
("projType")%></option>
<option value="Commercial">Commercial</option>
<option value="Housing">Housing</option>
<option value="In Progress">In Progress</option>
<option value="Null">Null</option>
<option value="Restaurant">Restaurant</option>
<option value="Retail">Retail</option>
</select>

How can I have the pulldown get its information from the
database (like it does in the form for creating the
record). This way, if my client creates new project
types, they are available without any further
intervention on my part.

-M
 
See this.
http://www.frontpagehowto.com/dynamicdrop/default.asp

If you have multiple records that share the same project
name, you will need an SQL like the following to filter
all of the duplicates down to one.

Select Results.Project, First(Results.FieldforSorting) AS
SomeName FROM Results GROUP BY Results.Project ORDER BY
First(Results.FieldforSorting) DESC

You may not need the sorting stuff.
 
How is that going to select the currently used projectype
and allow me to select a new one and post it back to the
database?

-M
 
Mike,

Here is how I would handle this:

I would have two tables in the database. Let call the main table, Projects and the other,
ProjectTypes.

<%
Set ProjectRS = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT projType FROM Projects"
ProjectRS.Open SQL, Conn

Set ProjectTypesRS = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT projType FROM ProjectTypes"
ProjectTypesRS.Open SQL, Conn
%>

<select size="1" name="projType">
<option selected value="<%=ProjectRS("projType")%>"><%=ProjectRS("projType")%></option>
<% while NOT ProjectTypesRS.EOF %>
<option value="<%=ProjectTypesRS("projType")%>"><%=ProjectTypesRS("projType")%></option>
<%
ProjectTypesRS.MoveNext
wend
ProjectTypesRS.Close
%>
</select>

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
Back
Top