Welcome Guest, Not a member yet? Register   Sign In
[WORKED AROUND] Passing a checkbox array... Nerve-racking.
#4

[eluser]Morty[/eluser]
I had to send an imploded version of my checkboxes then exploded via the PHP script.

JS :

Code:
function inline_results() {
    $filterstring = '';

    // alert(Form.serialize($('filter[]')));

    res = document.getElementsByName('filter[]')
    $filterstring = '';

    for (i = 0; i < res.length; i++)
        if (res[i].checked == true)
            if ($filterstring == '')
            {
                $filterstring += res[i].value;
            }
            else
            {
                $filterstring += '|'+res[i].value;
            }

    new Ajax.Updater ('stock_values', base_url+'stocks/ajaxstocksearch', {method:'post', postBody:'stock_site='+$F('stock_site')+'&stock;_product='+$F('stock_product')+'&filter;='+$filterstring});

With a simple :

Code:
$filter = explode("|", $filter);

to give back the array. I am not quite satisfied with the result, because an empty array/string is not really a FALSE boolean, but it will save me from drowning in despair.


Messages In This Thread
[WORKED AROUND] Passing a checkbox array... Nerve-racking. - by El Forum - 08-02-2007, 07:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB