Skip to content Skip to sidebar Skip to footer

How To Set The Value For Radio Button While Editing Using JQuery?

I've a radio button in my form and when I enter a reference number, I can fetch the corresponding form details along with source value using jQuery. I don't know how to set that va

Solution 1:

If you are looking to get the value of a selected radio button you can do this:

$('input[name="source"]:checked').val()

When you get the response from your ajax call you check your button:

First change this:

<input type="radio" ng-model="selected" name="source" class="source" id="VAT" value="VAT">VAT
<input type="radio" ng-model="selected" name="source" class="source" id="CST" value="CST">CST

$("#"+data.source).prop("checked", true)

This assune that your returned value is VAT or CST


Post a Comment for "How To Set The Value For Radio Button While Editing Using JQuery?"