Help, why idX="id"&n , response.write idX not working?

Discussion in 'C#' started by JJnacy, Dec 29, 2007.

  1. #1
    <%
    id1="yes"
    id2="yes"
    for n=1 to 2
    idX="id"&n
    if idX ="yes" then
    response.write idX&" ok"
    response.write "<br>"
    end if
    next
    %>


    <%
    id1="apple"
    n=1
    idX="id"&n
    response.write idX
    %>

    result
    I was expect result = " apple "
    But it shows " id1 " not " apple "
    Why and what the correct way to write?
     
    JJnacy, Dec 29, 2007 IP
  2. malkassem

    malkassem Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The code will not give you any response back.

    idx start at "id1" then "id2" as values. You probably want to call eval function like the following:

    <%
    id1="yes"
    id2="yes"
    for n=1 to 2
    idX= eval("id"&n)
    if idX ="yes" then
    response.write idX" ok"
    response.write "<br>"
    end if
    next
    %>

    hope this works for you!
     
    malkassem, Dec 29, 2007 IP
    JJnacy likes this.
  3. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks it works now.

    Rep for you and wish you Merry Christmas & Happy New year
     
    JJnacy, Dec 29, 2007 IP