How to set the value for radio button while editing using jQuery?
<p>I've a radio button in my form and when I enter a reference number, I can fetch the corresponding form details along with <strong>source</strong> value using <strong>jQuery</strong>. I don't know how to set that value to radio button. Thank You!</p>

<pre><code>&lt;input type="radio" ng-model="selected" name="source" class="source" &lt;?php echo ($row['source']=='VAT')?'checked':'' ?&gt; value="VAT"&gt;VAT
&lt;input type="radio" ng-model="selected" name="source" class="source" &lt;?php echo ($row['source']=='CST')?'checked':'' ?&gt; value="CST"&gt;CST
</code></pre>

<p>jQuery</p>

<pre><code>$('#gp_no').on('keypress', function(e){
    if(e.keyCode === 13)
    {
        $(this).trigger("enterKey");
        var val = $(this).val();
        var dataString = "gp_no=" + val;
        $.ajax({
            type: "POST",
            url: "post_process.php",
            data: dataString,
            dataType: 'json',
            success: function(data){
                $('.source').val(data.source);
            }
        });
    }
}); 
</code></pre>

<p>post_process.php</p>

<pre><code>if(ISSET($_POST['gp_no'])) {

    $gp_no = $con-&gt;real_escape_string($_POST['gp_no']);

    $query = "SELECT * FROM items WHERE items.gp_no = $gp_no";

    if ($result = $con-&gt;query($query)) {
        $row = $result-&gt;fetch_assoc();
        $source = $row['source'];
    }
    $json = array($vehicle_no, 'source' =&gt; $source);
    $json = json_encode($json);
    echo $json;
}
</code></pre>