How do you get the options from a select form? As a follow-up to my last question regarding creating a dynamic select using JavaScript and the Forms API, I'm now wondering how do you actually get the options from that select list in a submit function. I've read "How to get All options of a 'select' field?" but I have yet to get it working with my code. Maybe because this person is using a CCK field and I'm using the Forms API which as far as I've read works differently. I've also tried pulling the data from the $form_state as well as the $form with no luck. Below is my code for a more complete picture of what I'm trying to do:

function _jstest_form($form, &amp;$form_state) {
  $form['list'] = array(
    '#type' =&gt; 'select',
    '#options' =&gt; array('1', '2', '3'),
    '#size' =&gt; 4,
  );

  $form['text'] = array(
    '#type' =&gt; 'textfield',
  );

  $form['add_button'] = array (
    '#type' =&gt; 'button',
    '#value' =&gt; t("Add"),
    '#after_build' =&gt; array('_jstest_after_build'),
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Submit',
    '#submit' =&gt; array('_jstest_submit'),
    '#after_build' =&gt; array('_jstest_after_build'),
  );
  return $form;
}

function _jstest_submit($form, &amp;$form_state) {
  //  Do stuff with options from select
}
$form is the array build on server side, and it is not modified from JavaScript code executed from the browser, as that array is never passed to the browser. That is the reason why $form['list']['#options'] contains only the values set from the form builder.

The code that retrieves the value of $form is the following one, contained in drupal_build_form():

  // If the incoming input contains a form_build_id, we'll check the cache for a
  // copy of the form in question. If it's there, we don't have to rebuild the
  // form to proceed. In addition, if there is stored form_state data from a
  // previous step, we'll retrieve it so it can be passed on to the form
  // processing code.
  $check_cache = isset($form_state['input']['form_id']) &amp;&amp; $form_state['input']['form_id'] == $form_id &amp;&amp; !empty($form_state['input']['form_build_id']);
  if ($check_cache) {
    $form = form_get_cache($form_state['input']['form_build_id'], $form_state);
  }


When the form is submitted, that code retrieves the value of $form used to build the form.