How to use Form API and and node_submit to insert taxonomy data
Try this, if I completely understood you, this should help.

    $i = 0;
    foreach($form_state['values']['catagories'] as $tid) {
      $node-&gt;field_catagories[$node-&gt;language][$i]['tid'] = $tid;
      $i++;
    }