How To Display Checkboxlist Based On Selected Dropdownlist

Hi Yii-ers.

For example, I have this attribute in my table

id, id_karyawan, id_barang

I want to display this in my form :

id_karyawan --> dropdownlist

after selected id_karyawan, I want to display checkboxlist "id_barang" based on "id_karyawan" selected

Anyone can help me,

Thank you

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"/>');

})

1 Like

Thank you dragan.zivkovic, I will try this