views:

180

answers:

0

Ok, I am filling up my multiple select box with options from another select box via javascript like so:

function addAction()
{
    var actions = document.getElementById("actions");
    var action_list = document.getElementById("actions_list");
    var opt = document.createElement("option");
    for (var i=0; i<action_list.options.length; i++)
    {
        if (action_list.options[i].text == actions.options[actions.selectedIndex].text)
            return;
    }
    action_list.options.add(opt);
    opt.text = actions.options[actions.selectedIndex].text;
    opt.value = actions.options[actions.selectedIndex].value;
}

function removeActions()
{
    var action_list = document.getElementById("actions_list");
    for(i=action_list.options.length-1;i>=0;i--)
    {
        if (action_list.options[i].selected)
            action_list.remove(i);
    }
}

Now the following $layout_actions[] is returning EMPTY when I add values from 1 select box into this 1 via JS above:

echo '<select id="actions_list" name="layout_actions[]" multiple style="height: 128px; width: 300px;', (isset($context['layout_error']['no_actions']) ? ' border: 1px solid red;' : ''), '">';
                            foreach($context['current_actions'] as $cur_action)
                                echo '
                                    <option value="', $cur_action, '">', $cur_action, '</option>';  

        echo '
                                    </select>

In short, my $_POST['layout_actions'] = '' (empty string). What is going on here??? This should be working, shouldn't it be?

Please help me...argg. I know the elements are being added, as I can see them going from 1 select box to the muliple select box when I click on the Add Button, but when I post the form, layout_actions returns empty.