dongzouya5792 2011-05-10 17:48
浏览 33
已采纳

HTML表单未通过复选框

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 = '';
            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.

  • 写回答

1条回答 默认 最新

  • dsv768456 2011-05-10 17:49
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度