0

Custom bootstrap form, using SharePoint REST API, has text fields, checkboxes and radio buttons. Posting values from radio buttons work, value gets posted to a single line text column. However, on my edit form the radio buttons do not appear checked, text fields display data correctly (haven't even tried checkboxes yet).

$ajaxjj({
async:true,
url:_spPageContextInfo.webAbsoluteUrl + "/api/web/lists/GetByTitle('abc')/GetItemByID(" + value + ")",
method:"GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type":"application/json;odata=verbose"
},
success: function(data) {
console.log(data.d.Title);
$('#FirstName').val(data.d.firstName);
$('input:radio[name="q1"]').val(data.d.question1).prop('checked');

HTML

<div class="custom-control custom-radio">
      <input type="radio" class="custom-control-input qOne" id="q1y" name="q1" value="Yes">
      <label class="custom-control-label" for="q1y">Yes</label>
    </div>   
   <div class="custom-control custom-radio">
      <input type="radio" class="custom-control-input qOne" id="q1n" name="q1" value="No">
      <label class="custom-control-label" for="q1n">No</label>
    </div>

damooji
  • 21
  • 1
  • 4

1 Answers1

0

Figured it out.

$('input[name=q1][value=' + data.d.q1Response + ']').prop('checked',true);

damooji
  • 21
  • 1
  • 4