Getting values of multiple choice Field

I know this question has already been asked but the link to the helpdesk article no longer seems to work. I did try to use the suggestion I saw but something must not be right.

Also, the post I am referring to is from 2016 which may mean it may no longer be valid as there have been many updates to knack since and this question does not seem to be in any more recent posts. Therefore, I assume this is common knowledge but I am new to knack and jquery so I am at a loss as to how to get the value.

Any help would be wonderful.

Here is my code. I am trying to get the value of the multiple-choice field. both of these options return invalid.

$(document).on(‘knack-view-render.view_138’, function (event, view, data) {
$(‘#view_138-field_101’).change(function() {
alert ($(‘#view_138-field_103’).val());
var servicse = Knack.models[‘view_138’].toJSON().field_103_raw;
alert(services);
};
};

Try this

$(document).on('knack-view-render.view_138', function(event, view, data) {
  var multipleChoice = $('select#view_138-field_101')
  multipleChoice.change(function() {
    var selected = $(this).val()
    alert(selected)
  })
})

I tried the code… I am getting into the render function and past the Multiple choice declaration line. Not sure how to test of the mulitplechoice declaration actually returned anything but it passed it. However the call on Change to muilitplechoice does not fire. I assume maybe the declaration did not return the selected object.

is there a way to test for this?

I maybe should mention that the multiple choice is setup as a checkbox list where I can select multiple options. I am not sure if that makes a difference but maybe it does.

I have attached a screenshot of my form if it helps.
Knack image 1

thanks

Ah yeah. For checkboxes the code is slightly different. This should work:

$(document).on('knack-view-render.view_138', function(event, view, data) {
  $('input[name="field_103"]').change(function() {
    let checkboxes = $('input[name="field_103"]').each(function() {
      if (this.checked) {
        console.log('checked:', $(this).val())
      } else {
        console.log('not checked:', $(this).val())
      }
    })
  })
})

To see the results, open your console (e.g. On Chrome: Right Click the page, click Inspect, click the Console tab).