<% 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?
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!