Reputation: 11851
I have this radio button:
<td><input type="radio" name="training" value="yes"> Yes <input type="radio" name="training" value="no"> No</td>
And I am getting a data from a database via ajax call. The training value from the database is either yes or no.
My question is, how would I populate the radio buttons based off the value from the database.
Upvotes: 0
Views: 1991
Reputation: 20740
You can check radio button with value like following.
var valueFromDB="yes"; //assume this is your value from DB.
$('input[name=training][value=' + valueFromDB + ']').prop('checked', true);
Hope this will help you.
Upvotes: 1