Reputation: 3764
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.
Upvotes: 1
Views: 2883
Reputation: 3982
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.
Upvotes: 5