How to get selected select2 value and use it in my java code

Hi,

I’m coding a simple servlet plugin. I have a select2 list in my .vm which shows my project names. I want to get selected project name and show the issues inside it.

I need to get the project name and after that, I’ll find the project’s ID.

I wrote a code down below and I want to give project id as an function parameter. But I couldn’t figure it out how i can?

List<Long> currentIssueIds = projectManager.getIssueIdsForProject(PROJECTID);

Here is my select list.


<form id="admin" class="aui">
<label for="select2-example2">Choose a project:</label>
    <p>
        <select
        id="select2-example2"
        name="project"
        placeholder="Select a project">
        <option></option>
                #foreach( $pName in $pNames )
                    <option value="$pName"> $pName </option>
                #end
        </select>
</form>

<script>
AJS.$("#select2-example2").auiSelect2({placeholder: "Select a project", allowClear: true});
</script>

Waiting for your help, thanks already.