Get all selected data with javascript in multiple select field

Asked

Viewed 107 times

1

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

There are sectors, and in each sector there are several employees, and I need that when selecting a sector in a field select, the next field select (that will list the employees) be filled in with the employees of 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 field select of employees shall be loaded with the employees of these 2 sectors.

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

follows jsFiddle: https://jsfiddle.net/t0u1j6L8/4/

1 answer

2


Puts the attribute multiple select and then use $(this).val() to know the values selected. So

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

jsFiddle: https://jsfiddle.net/t0u1j6L8/6/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.