title: Conversion to array from listbox with jquery
body: <p>I've checked the other answers and they do not seem to address this issue:</p>
  
  <pre><code>  var values = [];
              $('#EnrolledParticipants :selected').each(function (i, option) {
                  values[i] = $(option).text();
              });
  </code></pre>
  
  <p>This returns an array with the number of elements equal to the number of selected options.</p>
  
  <p>However, what I would like to do is return an array with all of the contents in the listbox, not just the selected ones.</p>
  
  <p>When I do this code though:</p>
  
  <pre><code>  var values = [];
              $('#EnrolledParticipants').each(function (i, option) {
                  values[i] = $(option).text();
              });
  </code></pre>
  
  <p>It returns an array with one element and each of the options of the list box are separated by spaces.  Any idea what is different?  Is there a ":any" or something similar I could try?</p>
  
  <p>For additional info my ajax call looks like this:</p>
  
  <pre><code>$.ajax({
                  url: '@Url.Action("SaveStudy")',
                  type: "POST",
                  contentType: 'application/json',
                  data: JSON.stringify({
                      Participants: values,
                      StudyName: $("#StudyName").val(),
                      AssessmentID: $("input:radio:checked").val()
                  }),
                  success: function (result) {
  
                      $("#notify-container").notify("create", {
                          title: 'Update',
                          text: "Study was saved to database."
                      });
  
                  },
                  error: function () {
                      alert("No banks were selected.  Add at least one bank to create an assessment.");
                  }
              });
  </code></pre>
  
  <p>And my controller header looks like this:</p>
  
  <pre><code>public ActionResult SaveStudy(string StudyName, string AssessmentID, string[] Participants)
          {
  </code></pre>
  
  <p>Thank you!</p>