Iterate JSON object
<p>I have the following JSON Object:</p>

<pre><code>{
  "a1_1_on" : "on",
  "a1_1_thr" : "",
  "a1_2_on" : "on",
  "a1_2_thr" : "",
}
</code></pre>

<p>and I want using a for loop to check the fields for example:</p>

<pre><code>for (var i=1; i&lt;2; i++) {
    //alarm
    var al = 'ai_' + i + '_on';
    //alarm threshold
    var althr = 'ai_' + i + '_thr'

    //console.log(form_infos.al);

    if(form_infos.al == "on" &amp;&amp; form_infos.althr == "") {
        alert("Alarm for Analog " + i + "is on and you did not specified a threshold. Please specify a threshold before submittiing");
        return false;
    }
}
</code></pre>

<p>But it shows <code>undefined</code> if I do <code>console.log(form_infos.al)</code>. Any suggestions?</p>
