Returning Values from Tableselect Form with AJAX Objective: 

To combine AJAX Autocomplete with my Tableselect Form to create a key for users to select imported products that don't match existing products within your Drupal site. This new billing module would make it possible to use a specific 3rd party billing service. 

Issue:

I am unable to get the following code to return the values inserted via the AJAX row. The array continues to send back the array keys of the row as both keys and values. 
Here is what the original selection is: 

And here is the returned values:



As you can see the rows selected have their array key listed as the value on return, where as the non selected row has the value 0. 

Question: How do you change the return value so that it is the value that was selected on my AJAX form field?

function Test_product_form($form, &amp;$form_state)
{
  $form_state['page_num'] = 2;

  $form['Markup'] = array(
    '#markup' =&gt; t('Please select and synchronize Test Subscription Offers with your Drupal Commerce Product SKUS below:') . '&lt;/br&gt;' . '&lt;/br&gt;'
  );


  foreach ($form_state['sub_offers'] as $key =&gt; $offer) {
    if ($offer['Status'] == 'Active') {
      $product = commerce_product_load_by_sku($offer['OfferCode']) ? commerce_product_load_by_sku($offer['OfferCode']) : FALSE;

      if ($product === FALSE) {
        $rows[] = array(
          'Test Subscription Offers' =&gt; array(
            'data' =&gt; $offer['OfferCode'],
            'id' =&gt; 'row' . $key . '-aso',
            'class' =&gt; 'col-aso'
          ),
          'Drupal Product SKUS' =&gt; array(
            'data' =&gt; array(
              // drupal_get_form('commerce_product_line_item_add_form'),
              '#type' =&gt; 'textfield',
              '#title' =&gt; t('Product SKU'),
              '#description' =&gt; t('Enter the SKU of the product to add to the order.'),
              '#autocomplete_path' =&gt; 'commerce_product/autocomplete/commerce_product/line_item_product_selector/product',
              '#size' =&gt; 60,
              '#maxlength' =&gt; 255,
              //In order for AJAX within the Rows of tableselect form you must declare the 
              '#id' =&gt; $key . 'product_textfield'
            ),
            'id' =&gt; 'row' . $key . '-dps',
            'class' =&gt; 'col-dps'
          )
        );

      } else {
        $rows[] = array(
          'Test Subscription Offers' =&gt; array(
            'data' =&gt; $offer['OfferCode'],
            'id' =&gt; 'row' . $key . '-aso',
            'class' =&gt; 'col-aso'
          ),
          'Drupal Product SKUS' =&gt; array(
            'data' =&gt; array(
              '#type' =&gt; 'link',
              '#title' =&gt; $product-&gt;sku,
              '#href' =&gt; 'admin/commerce/products/' . $product-&gt;product_id
              // '#options' =&gt; $l_options,
              // '#suffix' =&gt; ' ' . theme('mark', array('type' =&gt; node_mark($node-&gt;nid, $node-&gt;changed))),
            ),
            'id' =&gt; 'row' . $key . '-dps',
            'class' =&gt; 'col-dps'
          )
        );
      }
    }
  }
  $hinput = array(
    'Test Subscription Offers' =&gt; 'aso',
    'Drupal Product SKUS' =&gt; 'dps'
  );


  foreach ($hinput as $hkey =&gt; $hvalue) {
    $header[$hkey] = array(
      'data' =&gt; $hkey,
      'id' =&gt; 'head-' . $hvalue,
      'class' =&gt; 'col-' . $hvalue
    );
  }

  $options = array();


  foreach ($rows as $key =&gt; $row) {
    $options[$key] = array(
      'Test Subscription Offers' =&gt; $row['Test Subscription Offers'],
      'Drupal Product SKUS' =&gt; $row['Drupal Product SKUS']
    );

  }

  $form['table'] = array(
    '#type' =&gt; 'tableselect',
    '#header' =&gt; $header,
    '#options' =&gt; $options,
    //'#js_select' =&gt; TRUE,
    '#multiple' =&gt; TRUE
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Submit',
    '#submit' =&gt; array(
      'Test_payment_submit_step_two'
    ),
    '#validate' =&gt; array(
      'Test_payment_validate_step_two'
    )
  );
  ddl_once($form);
  return ($form);

}
Short answer: you cannot use tableselect for submitting form elements.

Longer answer: the tableselect is for selecting one or multiple rows for further processing. You can check this through your submit handler only receiving one value for each row.

See http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#tableselect (it links to a full example on http://drupal.org/node/945102#drupal7).

If you really need a table form you could use dwillcox suggestion to use a theme function to render your form as described http://drupal.org/node/1587968

I'm not sure but have you thought about multiple forms on one page? That is each line from your tableselect attempt has it's own form. For this to work you need to implement a hook_forms(). I've used this for annotate module.

Some arguments about tableselect versus theming a form:


As table select adds radio or checkboxes it changes the complete form thus its meaning. The bad implementation of Drupal is it renders the form elements thus making the complete page looks like a form.
Theming your form is ugly as the exercise from http://drupal.org/node/1587968 shows. 


Some nitpicking one your code:


mixed case function names : violation of the coding standards
mixed case array keys:  this is not expected by most coders.
swapped the key and value for $hinput which makes it hard to maintain.


Let us know what solution you took.