This is more jQuery than Yii problem, maybe this could help:
add event listener on your select element. On change U can have selected value, based on what U can do your logic and just append id_barang checkbox in your form
something like this:
$(’#karywan_select’).on(‘change’, function() {
var idKarywan = $('option:selecte', $(this)).val();
// than do yor procedure to get id_barang
// and when U are ready
$('#yourForm').append('<input type="checkbox" value="id_barang"/>');