ASP Array?

K

kmdwebdesign

Hi,

I have a page in my admin system where the user can edit products they
have added. The problem I am having is with Related Products. These are
all listed in a multiple list. What I need to do is have those selected
when the product was added, already be highlighted in the multiple list
on the product edit page. Here is my post from another forum.
Appreciate if anyone could help.

Regards
SH

----

This is the recordset for the product they're editing

Dim rs_service
Dim rs_service_numRows

Set rs_service = Server.CreateObject("ADODB.Recordset")
rs_service.ActiveConnection = MM_covers_STRING
rs_service.Source = "SELECT * FROM tbl_services WHERE ID =
"+Request.QueryString("ID")+""
rs_service.CursorType = 0
rs_service.CursorLocation = 2
rs_service.LockType = 1
rs_service.Open()

rs_service_numRows = 0

This is the recordset to display ALL other products in the databse (so
they have ALL the products to select for a related product)

Dim rs_service2
Dim rs_service2_numRows

Set rs_service2 = Server.CreateObject("ADODB.Recordset")
rs_service2.ActiveConnection = MM_covers_STRING
rs_service2.Source = "SELECT * FROM tbl_services"
rs_service2.CursorType = 0
rs_service2.CursorLocation = 2
rs_service2.LockType = 1
rs_service2.Open()

rs_service2_numRows = 0

This is my session variable to receive the ID's of the related products
already entered

Dim rs_related__MMColParam
rs_related__MMColParam = rs_service.Fields.Item("related").Value

Here is my list as it is in simple format

<select name="related" size="3" multiple>
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_service2.EOF))
%>
<option
value="<%=(rs_service2.Fields.Item("ID").Value)%>"><%=(rs_service2.Fields.Item("name").Value)%></option>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_service2.MoveNext()
Wend
%>
</select>

So the above is currently just displaying ALL of the products. What I
need to do is highlight ("selected") automatically, those products that
ID appears in my session variable created earlier.

--
 
M

Mike Brind

Hi,

I have a page in my admin system where the user can edit products they
have added. The problem I am having is with Related Products. These are
all listed in a multiple list. What I need to do is have those selected
when the product was added, already be highlighted in the multiple list
on the product edit page. Here is my post from another forum.
Appreciate if anyone could help.

Regards
SH

----

This is the recordset for the product they're editing

Dim rs_service
Dim rs_service_numRows

Set rs_service = Server.CreateObject("ADODB.Recordset")
rs_service.ActiveConnection = MM_covers_STRING
rs_service.Source = "SELECT * FROM tbl_services WHERE ID =
"+Request.QueryString("ID")+""
rs_service.CursorType = 0
rs_service.CursorLocation = 2
rs_service.LockType = 1
rs_service.Open()

rs_service_numRows = 0

This is the recordset to display ALL other products in the databse (so
they have ALL the products to select for a related product)

Dim rs_service2
Dim rs_service2_numRows

Set rs_service2 = Server.CreateObject("ADODB.Recordset")
rs_service2.ActiveConnection = MM_covers_STRING
rs_service2.Source = "SELECT * FROM tbl_services"
rs_service2.CursorType = 0
rs_service2.CursorLocation = 2
rs_service2.LockType = 1
rs_service2.Open()

rs_service2_numRows = 0

This is my session variable to receive the ID's of the related products
already entered

Dim rs_related__MMColParam
rs_related__MMColParam = rs_service.Fields.Item("related").Value

Here is my list as it is in simple format

<select name="related" size="3" multiple>
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_service2.EOF))
%>
<option
value="<%=(rs_service2.Fields.Item("ID").Value)%>"><%=(rs_service2.Fields.Item("name").Value)%></option>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_service2.MoveNext()
Wend
%>
</select>

So the above is currently just displaying ALL of the products. What I
need to do is highlight ("selected") automatically, those products that
ID appears in my session variable created earlier.

--

Dreamweaver generated ASP code is inefficient, ugly and virtually
impossible to decipher. So I can't offer working code, but in
principal, I guess you are storing related product details in a
separate table? If so, on each iteration of your loop (Please stop
using While... Wend) you need to see if there is an entry in your
related products table for the one you are currently writing. If there
is, you need to response.write " selected" within the option tag.
 

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

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top