Ishan Dave
Ishan Dave

Reputation: 21

How to use value of variable's value in IF condition

Here, there is a variable "question", and that has a value that is variable too that is "Q4_1", and I need to execute if the condition on the basis of that value of "Q4_1". So how should I call the variable's variable's value?

question="Q4_1"

<%if (value of (=question)="1"  then %>            
    <tr><td>Some text</td></tr>
<%end if %> 

Upvotes: 2

Views: 205

Answers (1)

kloarubeek
kloarubeek

Reputation: 2844

You're looking for the Eval() function to evaluate an expression:

Dim question
Dim Q4_1

question ="Q4_1"
Q4_1 = "1"   
If Eval(question) = "1"  Then
    Response.Write "Some text"
Else
    Response.Write "Other text"
End If

This example will send "Some text" to the client.

Upvotes: 3

Related Questions