When rendering the page, the val()
of a multiple select is set with a single value. For example, $("#my_select_box").val(1);
Then the user selects an additional value in the multiple select box.
When the form is submitted, only the newly selected value is submitted and not the previously set one. Whereas while debugging in Firefox, the .val()
function returns an array of two values (both the previous one and the newly selected one). Why does this happen?
parse_str()
will not work, as it will throw out the duplicate elements. There is a simple function namedproper_parse_str()
that will work, available at php.net/manual/en/function.parse-str.php#76792 – Salpa