PHP: Get selected items from selection list
<p>I creating a  web based user order portal. I have a list with all user groups. You can select multiple groups and can add it to another list (selectedGroups). In the selectedGroups-list you can also remove items. That works pretty fine!</p>

<p>The lists construction is in my order.php. After you submitted the order you get a summary site (save.php). On this page, I need all items from the selectedGroups list. Unfournately <code>$__POST</code>, <code>$_GET</code> and many other ways did not work. I am getting other attributes from the order.php in save.php.</p>

<p>This is the list in my order.php:</p>

<pre><code>&lt;select id="SelectedGroups" name="SelectedGroups[]" size="5" multiple disabled="true"&gt; 
&lt;/select&gt;
</code></pre>

<p>(the selection list is just on initialization diabled)</p>

<p>This is my current code in save.php:</p>

<pre><code>$Selection = $_POST['SelectedGroups'];

if(empty($Selection)) {
    echo 'Es wurde keine Gruppe ausgewählt!';
} else {
    foreach ($Selection as $selectedOption) {
        echo($selectedOption . "&lt;/br&gt;");
    }
}
</code></pre>

<p>But I tried many different ways. Never time I get the SelectedGroups-Items.</p>

<p>Thanks in advance for any help!</p>

<p>--- Edit: 14.04., 13:55 --- </p>

<p>This code fill the "Groups"-List:</p>

<pre><code>&lt;?php

                                # Abfrage
                                $result = null;
                                $sql= 'SELECT * FROM dbo.Groups';
                                $query = sqlsrv_query($conn,$sql);

                                if (sqlsrv_has_rows($query)){
                                    while ($row = sqlsrv_fetch_array($query)){
                                        $result[] = $row['Groupname'];
                                    }
                                }


                                echo "&lt;select id='Groups' name='Groups' size='5' multiple disabled='true'&gt;";
                                    for($i = 0; $i &lt; count($result);$i++){
                                        echo "&lt;option value=". $i ."&gt;" . $result[$i] . "&lt;/option&gt;";
                                    }
                                echo "&lt;/select&gt;";

                                    ?&gt;
</code></pre>

<p>And with this I transfer the entry from "Groups" to "selectedGroups":</p>

<pre><code>&lt;label&gt;&lt;input type="button" value="Hinzuf&amp;uuml;gen" id="btn_add" name="add" disabled="false" onclick="move(this.form.Groups,this.form.SelectedGroups);"/&gt;&lt;/label&gt;
</code></pre>

<p>--- Edit: 15.04., 11:45 --- 
the form line:</p>

<pre><code>&lt;form action="./index.php" method="get" novalidate autocomplete="off" class="idealforms"&gt;
</code></pre>