Catch all data selected with javascript in multiple select field

1

I'll describe what I'm trying to do:

There are sectors, and in each sector there are several employees, and I need to, when selecting a sector in a select field, the next field select (which will list employees) be filled with employees in this sector.

The problem is that it may be possible to select more than one sector (the sector field is multiple ), that is, when selecting 2 different sectors, the select field of employees should be loaded with the employees of these 2 sectors.

I'm not sure how to send all the sector IDs to my PHP file that will return the code with all employees.

follow jsFiddle: link

    
asked by anonymous 23.05.2016 / 22:25

1 answer

2

Places the multiple attribute in the select and then uses $(this).val() to know the selected values. So

$.post('_require/_jp/jpcarregafuncionario.php', {
        id_fun: $(this).val()
    }, function(res) {

jsFiddle: link

    
23.05.2016 / 22:36