ASP Array?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kmdwebdesign@gmail.com

    ASP Array?

    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_numR ows

    Set rs_service = Server.CreateOb ject("ADODB.Rec ordset")
    rs_service.Acti veConnection = MM_covers_STRIN G
    rs_service.Sour ce = "SELECT * FROM tbl_services WHERE ID =
    "+Request.Query String("ID")+""
    rs_service.Curs orType = 0
    rs_service.Curs orLocation = 2
    rs_service.Lock Type = 1
    rs_service.Open ()

    rs_service_numR ows = 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_num Rows

    Set rs_service2 = Server.CreateOb ject("ADODB.Rec ordset")
    rs_service2.Act iveConnection = MM_covers_STRIN G
    rs_service2.Sou rce = "SELECT * FROM tbl_services"
    rs_service2.Cur sorType = 0
    rs_service2.Cur sorLocation = 2
    rs_service2.Loc kType = 1
    rs_service2.Ope n()

    rs_service2_num Rows = 0

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

    Dim rs_related__MMC olParam
    rs_related__MMC olParam = rs_service.Fiel ds.Item("relate d").Value

    Here is my list as it is in simple format

    <select name="related" size="3" multiple>
    <%
    While ((Repeat1__numR ows <0) AND (NOT rs_service2.EOF ))
    %>
    <option
    value="<%=(rs_s ervice2.Fields. Item("ID").Valu e)%>"><%=(rs_se rvice2.Fields.I tem("name").Val ue)%></option>
    <%
    Repeat1__index= Repeat1__index+ 1
    Repeat1__numRow s=Repeat1__numR ows-1
    rs_service2.Mov eNext()
    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.

    --

  • Mike Brind

    #2
    Re: ASP Array?


    kmdwebdesign@gm ail.com wrote:
    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_numR ows
    >
    Set rs_service = Server.CreateOb ject("ADODB.Rec ordset")
    rs_service.Acti veConnection = MM_covers_STRIN G
    rs_service.Sour ce = "SELECT * FROM tbl_services WHERE ID =
    "+Request.Query String("ID")+""
    rs_service.Curs orType = 0
    rs_service.Curs orLocation = 2
    rs_service.Lock Type = 1
    rs_service.Open ()
    >
    rs_service_numR ows = 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_num Rows
    >
    Set rs_service2 = Server.CreateOb ject("ADODB.Rec ordset")
    rs_service2.Act iveConnection = MM_covers_STRIN G
    rs_service2.Sou rce = "SELECT * FROM tbl_services"
    rs_service2.Cur sorType = 0
    rs_service2.Cur sorLocation = 2
    rs_service2.Loc kType = 1
    rs_service2.Ope n()
    >
    rs_service2_num Rows = 0
    >
    This is my session variable to receive the ID's of the related products
    already entered
    >
    Dim rs_related__MMC olParam
    rs_related__MMC olParam = rs_service.Fiel ds.Item("relate d").Value
    >
    Here is my list as it is in simple format
    >
    <select name="related" size="3" multiple>
    <%
    While ((Repeat1__numR ows <0) AND (NOT rs_service2.EOF ))
    %>
    <option
    value="<%=(rs_s ervice2.Fields. Item("ID").Valu e)%>"><%=(rs_se rvice2.Fields.I tem("name").Val ue)%></option>
    <%
    Repeat1__index= Repeat1__index+ 1
    Repeat1__numRow s=Repeat1__numR ows-1
    rs_service2.Mov eNext()
    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.

    --
    Mike Brind

    Comment

    Working...