Open Source & Stuff  
  |     Main Site     |      Forum     |     Contact     |
Ajax Linked Select boxes :  forum.Salix.gr forum.Salix.gr
Comments, questions, usage, bugs. 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
messagesc_form_elements: multiple select returns only one value
Posted by: ste (IP Logged)
Date: September 08, 2008 09:06AM

Hi Panos,
I tried your sc_forms_elements with select. If I try with MULTIPLE only one value is returned, exactly the last one and a count($_POST['my_select']) gives one.

CODE:
$sc_forms_countries = new sc_form_elements();
$list = $sc_forms_countries->get_list_from_db('countries','id', $_SESSION['lang'], $_SESSION['lang']);
$sc_forms_countries->add_select_box($list, $countries, 'sel_countries', 'sel_countries_id', 'class="text"', TRUE, 3);

I saw that in the Html generated code the name of the select is 'sel_countries' and not 'sel_countries[]' with brackets as it should be for a multiple select. So I added [] in the code above, but the array is empty, no value. The demo page has no button to see the result.

Another question: why did you not put the parameter 'select_prompt_text' like you did in linked selects? It is very useful.
Thanks for your work and answer.
Ste

messageRe: sc_form_elements: multiple select returns only one value
Posted by: panos (IP Logged)
Date: September 12, 2008 02:39AM

Hi,
you are right, generated code should have [] in name property of select.
if you added to the name it will work

$sc_forms_countries->add_select_box($list, $countries, 'sel_countries[]', 'sel_countries_id', 'class="text"', TRUE, 3);

select_prompt_text is a property of that class. You can check select_prompt_key, select_prompt_text, select_add_prompt_row properties in the doc page.

Sorry for the late response and atleast it helped.

Best regards
Panos

messageRe: sc_form_elements: multiple select returns only one value
Posted by: ste (IP Logged)
Date: September 15, 2008 01:02AM

Hi Panos,
thanks for your answer, it helped, now the array $_POST['sel_countries'] contains the selected values.
But I can't make the parameter "selected" work properly yet.

Example:

having the code

$sc_forms_countries = new sc_form_elements();
$list = $sc_forms_countries->get_list_from_db('countries','id', $_SESSION['lang'], $_SESSION['lang']);
$sc_forms_countries->add_select_box($list, $_POST['sel_countries'], 'sel_countries[]', 'sel_countries_id', 'class="text"', TRUE, 3);

I select a couple of countries. If I reload the form with $_SERVER['PHP_SELF'] I'd expect to find the items contained in $_POST['sel_countries'] selected in the select, but no selection appears. Where is my error? In non MULTIPLE selects the parameter "selected" works fine.

Thanks
Ste

messageRe: sc_form_elements: multiple select returns only one value
Posted by: panos (IP Logged)
Date: September 15, 2008 05:17AM

just checked the code and $selected parameter expects comma separated the values for multi select.
I think if you change to implode(',',$_POST['sel_countries']) it will work.

Best regards
Panos

messageRe: sc_form_elements: multiple select returns only one value
Posted by: ste (IP Logged)
Date: September 15, 2008 10:27AM

Hi Panos,
that was the right solution.
Thanks for your nice scripts and the great support to forum people.
Best regards.
Ste



Sorry, only registered users may post in this forum.

All Rights Reserved 2006 Salix.gr  |  Design by Ades Design |  Hosting by e-emporio |  forum.Salix.gr powered by Phorum