combo box

E

Eugene Anthony

I actually have two combo box on my .asp with the simular code as
bellow:

<select name="select2" class="TextField1">
<%
openDB()

set rs = Server.CreateObject("ADODB.Recordset")
objConn.usp_RetrieveCategories rs

do while not rs.eof
response.write "<option value=" & rs(0) & ">" & rs(1)
rs.movenext
loop

closeRS()
closeDB()
%>
</select>


The stored procedure is as bellow:

create procedure usp_retrieveCategories
AS SET NOCOUNT ON

SELECT CategoryID, CategoryDescription FROM categories

Return
GO


Now I have a table called ProductsCategories:

create table ProductsCategories
(
ItemID int,
CategoryID int
);


I also have the ItemID stored as:

ItemID = formatforDb(Request.QueryString("ItemID"))


Now what I intend to do is lets say I have ItemID 1 in
ProductsCategories table. ItemID 1 can have one or two CategoryID in
ProductsCategories table. If ItemID 1 has only one CategoryID, then the
combobox 1 should focus the CategoryID found in ProductsCategories
table. If suppose ItemID 1 has two CategoryID in ProductsCategories
table, then the first CategoryID of ProductsCategories table should be
the focused on combobox1 and the second CategoryID of ProductsCategories
table should be the focus on combobox2.

For example:

<select name="select1" class="TextField1">
<%
openDB()

set rs = Server.CreateObject("ADODB.Recordset")
objConn.usp_RetrieveCategories rs

do while not rs.eof
%>
<option value='<%=rs(0)%>' <% if rs(0)=Parent then response.write
"selected" end if %>><% =rs(1) %></option>
<%
rs.movenext
loop

closeRS()
closeDB()
%>
</select>

The purpose of the codes above is to modify an existing information
stored in the database.

How is it done?. Your help is kindly appreciated.

Regards

Eugene Anthony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

fill combo box with data from database 4
Paging 0
Arrays 0
Combo box on ASP page 2
Error: Object is closed 1
how to show more than column value in combo box 2
resources - stored procedure 5
asp and ms sql 10

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top