开发者

$_POST Returns empty for multiple select box

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[acti开发者_如何学编程ons.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.


I tried your code in simple HTML and It is displaying Array of layout_actions[] in request

What I seen that You use Variable $context in single quote ....

so I think that is the reson why it is not taking Multiple property of select Box

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜