Hi all, i'm new to asp.. and i have sum qns too ask from u guys...
i have search for tis ans for quite sum times.. it may sounds abit easy for u guys but really hope sum1 cld help mi...
I have 2 tables, 1 table is to contain de data tt can be used to display de options in ddl.. For example, in tis ddl, i ave Cat and Dog.
I have selected dog and info is stored in another table..
I want to retrieve tis dog info out and display in a ddl.
For de ddl, as usual, i used de 1st table to display all de data and use another table to display de selected value..
But at tis pt of time, i only noe how to display de items in ddl, but nt de selected value... i have did tis in asp.net, and it seems abit diff from tt...
Appreciate alot if sum1 cld help mi solve tis.. thanx!!!
Code:
<%
Catgeory refers to the info tt was saved previously(1 of de option in de catagory. For example, in Catgeory ddl, there's 2 options, Cat and Dog. Catgeory here refers to mayb, dog.
Set rs_vEmail = Server.CreateObject("ADODB.Recordset")
rs_vEmail.ActiveConnection = MM_dsprms_STRING
rs_vEmail.Source = "SELECT ID, Name, Email_Add, Category FROM Email_Address"
rs_vEmail.CursorType = 0
rs_vEmail.CursorLocation = 2
rs_vEmail.LockType = 1
rs_vEmail.Open()
TheArray = rs_vEmail.GetRows
'This is to get the data from the db to display de items in the ddl. E.G, Dog and Cat
Dim rs_vCategory 'recordset to capture category from category table
Set rs_vCategory = Server.CreateObject("ADODB.Recordset")
rs_vCategory.ActiveConnection = MM_dsprms_STRING
rs_vCategory.Source = "SELECT category FROM Category"
rs_vCategory.CursorType = 0
rs_vCategory.CursorLocation = 2
rs_vCategory.LockType = 1
rs_vCategory.Open()
%>
' This is to display de items in de ddl. But how do i select (display) de items tt i retrieve from the db?
<html>
<td><select name="category" id="select">
<%
While (NOT rs_vCategory.EOF)
%>
<option value="<%=(rs_vCategory.Fields.Item("category").Value)%>"><%=(rs_vCategory.Fields.Item("category").Value)%></option>
<%
rs_vCategory.MoveNext()
Wend
If (rs_vCategory.CursorType > 0) Then
rs_vCategory.MoveFirst
Else
rs_vCategory.Requery
End If
</html>