复选框取消选中IE10 + IE11的问题

I have a big problem with IE 10 and checkboxes. I use some checkboxes like this:

<form method="post" action="">
    <input id="trainingseinheit1" type="checkbox" checked="checked" value="1" name="trainingseinheit1"> 1
    <br>
    <input id="trainingseinheit2" type="checkbox" checked="checked" value="2" name="trainingseinheit2"> 2
    <br>
    <input id="trainingseinheit3" type="checkbox" checked="checked" value="3" name="trainingseinheit3"> 3
    <br>
    <input id="trainingseinheit4" type="checkbox" checked="checked" value="4" name="trainingseinheit4"> 4
    <br>
    <input id="trainingseinheit5" type="checkbox" checked="checked" value="5" name="trainingseinheit5"> 5
    <br>
    <input id="trainingseinheit6" type="checkbox" checked="checked" value="6" name="trainingseinheit6"> 6
    <input type="hidden" name="teanzahl" value="6" />
</form>

And after sending I will check with php which checkbox is checked and do something:

$zahl = 1;

while($zahl <= $_POST['teanzahl'])
{
    $tezahl = "trainingseinheit".$zahl;

    if(isset($_POST[$tezahl]))
    {
        // do something ...
    }

    $zahl++;  
}

In Firefox, Chrome etc it works fine. The PHP code realize which elements are checked and which not. But in IE10 and IE11 it thinks that all elements are checked (even if I uncheck all). Another strange thing is, when I echo the value of the checkbox field like this:

echo $tezahl." = ".$_POST[$tezahl]." ... ";

In Firefox it looks like this:

trainingseinheit1 = 1 ... 
trainingseinheit2 = 2 ... 
trainingseinheit3 = 3 ... 
trainingseinheit4 = 4 ... 
...

But in IE10 it looks like this:

trainingseinheit1 = 1 ... 
trainingseinheit2 = 1 ... 
trainingseinheit3 = 1 ... 
trainingseinheit4 = 1 ... 
...

So in IE it is always the value "1". Why that?

I don't know what I have to change for IE. Do you have a idea?

查看全部
dongshuming7131
dongshuming7131
2013/12/09 13:27
  • Internet-explorer
  • checkbox
  • php
  • 点赞
  • 收藏
  • 回答
    私信

1个回复