how to automatically retrieve selected value is there a way to automatically retrieve selected value from dropdown or radio to form below? example in the image below, if i select radio button "randy", then the value "randy" automatically fill in the form Nama below



$header1 = array('Name'); // Prepare table header
$query = db_select("homo", "r"); // Select table  
$query-&gt;fields("r", array("nama")); // Select fields    
$result = $query-&gt;execute(); // Execute query 
$rows = array();
while($data = $result-&gt;fetchObject()){ // Looping for filling the table rows  
$rows[] = array( // Fill the table rows
  $data-&gt;nama,
  );
}
$form['table'] = array (
 '#type' =&gt; 'tableselect',
 '#header' =&gt; $header1,
 '#options' =&gt; $rows,
 '#multiple' =&gt; FALSE,  
);
$form['f1'] = array(
 '#title' =&gt; t('Detail Anggota'),
 '#type' =&gt; 'fieldset',    
);
$form['f1']['namaa'] = array(
 '#title' =&gt; t('Nama'),
 '#type' =&gt; 'textfield',    
 '#required' =&gt; TRUE,
);
You need to use Form API Ajax. There you can see how to use it, Examples for developers include good ajax forms too.

Just remember, to set value to display, use $form_state['input'], not $form_state['values'].