Hi All,

I have an tableselect and submit button. When I click to the submit button - ajax will call to the function and I want to get the value of rows which are selected in the table select. How can I do it?

I also try $value = $form_state[value][table] but it returned for me an array, not an ID value of row. In this case I also checked 1 row.

Thanks

Comments

Jaypan’s picture

Non-selected rows will have a value of zero. Selected rows will have the value of the selected checkbox/radio.

For example, if your options are:

array(
1 => 'One',
'Sunday' => 'Sunday',
9 => 'nine',
);

And you selected Sunday and nine, $form_state['values']['table'] would be:

array(
1 => 0,
'Sunday' => 'Sunday',
9 => 9,
);
ken nguyen’s picture

Hi jaypan,

I have
$tests = $form_state['values']['table'];

foreach(tests As test) {
$options = array (
test -> value , ??? Is it right
);
}

As your example, I want to print 'Sunday' so how can i do it?

Thanks for your help too much

Jaypan’s picture

You cannot print in submit functions.

I'm not entirely clear on what you want to achieve.

ken nguyen’s picture

Hi Jaypan,

Sorry for make you confuse.

Actually I have a select list and a tableselect.
The first I will check a row on table which will be updated value.
Then I will select an option of select list and the ajax will be called back.
The value of the row of table which is checked before will be updated by the value of an option of select list

Jaypan’s picture

So where are you trying to get the value of the table select? In a submit function?

ken nguyen’s picture

Yes. Do you have any ideas?

Jaypan’s picture

if($form_state['values']['table']['Sunday'] == 'Sunday')
{
  // The user has selected 'Sunday'
}