ASP Array?

Discussion in 'ASP General' started by kmdwebdesign@gmail.com, Jul 13, 2006.

  1. Guest

    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.

    --
    , Jul 13, 2006
    #1
    1. Advertising

  2. Mike Brind Guest

    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_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.

    --
    Mike Brind
    Mike Brind, Jul 13, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel
    Replies:
    1
    Views:
    1,029
    Kevin Collins
    Aug 14, 2003
  2. Mara Guida

    const and array of array (of array ...)

    Mara Guida, Sep 2, 2009, in forum: C Programming
    Replies:
    3
    Views:
    463
    David RF
    Sep 3, 2009
  3. Steve Kuhn
    Replies:
    2
    Views:
    345
    majiofpersia
    Jul 29, 2003
  4. Tom
    Replies:
    3
    Views:
    186
    salsablr
    Dec 20, 2004
  5. Tuan  Bui
    Replies:
    14
    Views:
    451
    it_says_BALLS_on_your forehead
    Jul 29, 2005
Loading...

Share This Page