Select appropriate radio buttons from JSON via a loop
<p>I am getting a <code>JSON</code> and I'm populating my form's controls with the relevant data. 
All the controls work fine except the <code>radio buttons</code>. In my database I have the values for the radio buttons saved as <code>BIT</code>.</p>

<p>So, I'm parsing the JSON and looping for each control and assign it's value. However, it seems like I'm doing something wrong for on the <code>radio buttons</code> (maybe the case statement or my html). Any ideas?</p>

<ul>
<li>I'm using jQuery 1.9</li>
</ul>

<p>HTML</p>

<pre><code>            &lt;div class="col-sm-5"&gt;
                &lt;label class="radio-inline"&gt;
                    &lt;input type="radio" class="myform" value="1" name="testx"&gt;
                    YES
                &lt;/label&gt;
                &lt;label class="radio-inline"&gt;
                    &lt;input type="radio" class="myform" value="0" name="testx"&gt;
                    NO
                &lt;/label&gt;

            &lt;/div&gt;

            &lt;div class="col-sm-5"&gt;
                &lt;label class="radio-inline"&gt;
                    &lt;input type="radio" class="myform" value="1" name="highdanger"&gt;
                    YES
                &lt;/label&gt;
                &lt;label class="radio-inline"&gt;
                    &lt;input type="radio" class="myform" value="0" name="highdanger"&gt;
                    NO
                &lt;/label&gt;
            &lt;/div&gt;
</code></pre>

<p>My loop</p>

<pre><code>     $.ajax({
         type: "GET",
         cache: false,
         url: serviceUrl + "/ModuleTask/GetExamination" + qstring,
        // beforeSend: sf.setModuleHeaders,
         contentType: "application/json; charset=utf-8"
     }).done(function (result) {
         var oResult = JSON.parse(result);

         // reset form values from json object
         $.each(oResult, function (name, val) {
             var $el = $('[name="' + name + '"]'),
                 type = $el.attr('type');

             switch (type) {
                 case 'checkbox':
                     $el.attr('checked', 'checked');
                     break;
                 case 'radio':
                     // $el.filter('[value="' + val + '"]').attr('checked', 'checked');
                     //$el.attr('checked', 'checked');
                    // $el.prop("checked", val);
                     //$el.filter('[value="' + val + '"]').prop("checked", true);
                    // $el.filter('[value="' + true + '"]').val(1);
                     $el.filter('[value="' + val + '"]').prop("checked", true);
                     break;
                 default:
                     $el.val(val);
             }
         });


     }).fail(function (xhr, result, status) {
         alert(result);
     });
</code></pre>

<p>AJAX response</p>

<pre><code>{"ExaminationID":1,"UserID":44,"PortalID":0,"bloodcholisterol":1,"bloodldl":2,"bloodhdl":3,"bloodtriglycerides":4,"bloodglucose":5,"bodyweight":6,"bodyheight":7,"bodycircumference":8,"bodyexaminer":"DD","bodycomments":"a1","pressurestarttime":null,"pressureone":100,"pressuretwo":200,"pressurethree":300,"pressureexaminer":"B","pressurecomments":"B1","FileID":null,"agogiartiriakipiesi":null,"agogilipidia":null,"agogisakxarodidiaviti":null,"examinationcomments":"c1","highdanger":false,"sistaseis":"no sistaseis","axiologisiexaminer":"XH"}
</code></pre>