开发者

HTML form doesn't pass the checkbox

Why doesn't the next code pass the "games" as an array to the php?

<script type="text/javascript">
    function buildAndSubmitForm(index){
        <?  $args = 't='.$team.'&s='.$season.'&l='.$league.'&f='.$flag;
            $inputs 开发者_JAVA百科= '';
            foreach($games as $game)
                $inputs .= '<input type="checkbox" name="games[]" id="games[]" value="'.$game.'" />';
        ?>
        var form = '<?='<form name="myForm" id="myForm" action="scr'?>';
        form = form.concat(index);
        form = form.concat('<?='.php?'.$args.'" method="post">'.$inputs.'</form>'?>');
        $('#formDiv').html(form);
        $('#myForm').submit();
    }
</script>
<div style="display: inline">
    <div name="formDiv" id="formDiv" style="display: none;"></div>
    <a href="#" onclick="buildAndSubmitForm('a')">Home Stats</a>
    <a href="#" onclick="buildAndSubmitForm('b')">Visit Stats</a>
    <a href="#" onclick="buildAndSubmitForm('c')">Wins VS Losses</a>
    <a href="#" onclick="buildAndSubmitForm('d')">Home VS Visit</a>
    <a href="#" onclick="buildAndSubmitForm('e')">Overall</a>
</div>

I checked in the firebug, it seems to create a right form up until the submit, then it just doesn't pass the checkbox array.


You should give your checkbox the attribute checked. Otherwise it will not be submitted. This is specified in the HTML specs as a form-element that is not successful.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜