JSFiddle - React, Tailwind, and code Playground

HTML

<select multiple>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
</select>
<input type='submit' name='submit' />

JavaScript

$('[name=submit]').click(function(e){
    e.preventDefault();
    var array = [];
    $('select :selected').each(function(i,value){
        array[i] = $(this).val();
    });
    //here make your ajax call to a php file, and loop through array.
});