<form method="post" id="ajax_form">
<label for="required_services_input">Тип услуги</label>
<select class="form-control" id="select_required_services" name="OFFER_TYPE[]" multiple>
<option value="SERT">Сертификация</option>
<option value="TO">ТО</option>
<option value="TEO">ТЭО</option>
<option value="ADVICE">Консультация</option>
</select>
</form>
<script>
$(document).ready(function () {
$('#select_required_services').on('change', function (event) {
let select = $(this);
$.ajax({
url: 'my_url',
type: "POST",
data: select.closest('form').serialize(),
success: function(response) {
console.log(response);
}
});
});
});
</script>
<?php
echo json_encode($_POST['OFFER_TYPE']);
// Обрабатываем, как обычный массив
// foreach ($_POST['OFFER_TYPE'] as $offer) {
// echo $offer;
// }
<?php
class DBworker
{
public function countUsers()
{
// TODO: реализовать проверку в БД
}
}
class Validation
{
private $db;
public function __construct(DBWorker $db)
{
$this->db = $db;
}
public function uniqueUsers()
{
$this->db->countUsers();
}
}