How can multipleselect be used in the form submission page to get the selected value?

problem description

formmultipleselect

the environmental background of the problems and what methods you have tried

js

related codes

/ / Please paste the code text below (do not replace the code with pictures)
$("- sharpmultiselect") .change (function () {

         $("select :selected").each(function() {
            str +=","+$(this).val();
         });
         //strformaction
});

what result do you expect? What is the error message actually seen?


the official http://api.jquery.com/val/ document contains the following description

When the first element in the collection is a select-multiple (i.e., a select element with the multiple attribute set), .val () returns an array containing the value of each selected option. As of jQuery 3.0, if no options are selected, it returns an empty array; prior to jQuery 3.0, it returns null.

so the following code can get the selected value

<select id="elem" multiple="multiple">
    <option>...</option>
    ...
</select>
var values = $('-sharpelem').val();
Menu