title: How to get all the selected options in a drop down list with JavaScript?
body: <p>I have a drop down list, and user can select multi options.</p>
  
  <p>So this is part of my code in firtfile.inc</p>
  
  <pre><code>            &lt;div class="col-md-8"&gt;
                  &lt;!-- Change report heading so we can grab it on the report page --&gt;
                      &lt;select name="SearchIn[]" multiple="multiple"  onchange="javascript:this.form.Heading.value=this.options[this.selectedIndex].text;" required="required" title="Section"&gt;
  
                      &lt;option value="" disabled selected&gt;Select&lt;/option&gt;
                      &lt;?php
  //Loop over the options
  
   for($i=0;$i&lt;sizeof($SearchCriteria);$i++){
    ?&gt;
  
          &lt;option value="&lt;?php echo $SearchCriteria[$i]['value'];?&gt;"&lt;?php if($SearchCriteria[$i]['value']=='FacultyName'){echo ' selected="selected"';}?&gt;&gt;
          &lt;?php echo $SearchCriteria[$i]['display'];?&gt;
          &lt;/option&gt;
     &lt;?php
       }//!End of looping over search criteria
        ?&gt;
                      &lt;/select&gt;
      &lt;!-- Hidden heading field for search report --&gt;
                      &lt;input type="hidden" name="Heading" valtue="" /&gt;
  
                  &lt;/div&gt;
  </code></pre>
  
  <p>in another php file, I have included  firstfile.inc, and i want to get the list of options that user has selected from drop down list.
  so I have the folloing in the php file to get the selected options.</p>
  
  <pre><code>  $Heading = $dat-&gt;if_default('Heading', '');
  </code></pre>
  
  <p>but it only gives me the first option that the user has selected, but I need  all of them. How can I get them?</p>