【问题标题】:Some checkboxes won't work (HTML,PHP)某些复选框不起作用(HTML、PHP)
【发布时间】:2017-09-20 18:03:12
【问题描述】:

在一个页面上,我有大约 40 个复选框。只有最后一个可以在我的 android-browser 上运行。在我的电脑(Internet Explorer、chrome、Firefox)上一切正常。

请看这里: stufentheorie.de / tonart-bestimmen.html

代码如下:

   <form action='' method='post' role='form'>

<div class="row">
  <div class="col-md-4">
<p>&nbsp;</p>
<h3>Dur-Akkorde</h3>

 <?
$i = "0";
foreach ($toene as $ton)
{
    $wert = $ton . " " . $geschlecht[0];
    $ch = '';
    if (is_array($input_chord) == true)
    {
        if (in_array($wert, $input_chord))
        {
            $ch = " checked=\"checked\"";
        }
    }
    echo "<span style=\"width:120px;display:block;float:left;\"><input type=\"checkbox\"  name=\"akkord[".$wert."]\" value=\"" . $wert . "\"" . $ch . "> " . $wert . " </span>";
    $i ++;
    if ($i % 6 == 0)
    {
        echo "";
    }


}

?>

</div>
  <div class="col-md-4">
<br style="clear:left;" />
<h3>Moll-Akkorde</h3>



 <?
$i = "0";
foreach ($toene as $ton)
{
    $wert = $ton . " " . $geschlecht[1];
    $ch = '';
    if (is_array($input_chord) == true)
    {
        if (in_array($wert, $input_chord))
        {
            $ch = " checked=\"checked\"";
        }
    }
    echo "<span style=\"width:120px;display:block;float:left;\"><input type=\"checkbox\" name=\"akkord[".$wert."]\" value=\"" . $wert . "\"" . $ch . "> " . $wert . " </span> ";
    $i ++;
    if ($i % 5 == 0)
    {
        echo "";
    }


}

?> 
</div>
  <div class="col-md-4">
<br style="clear:left;" />
<h3>Verminderte Akkorde</h3>



 <?
$i = "0";
foreach ($toene as $ton)
{
    $wert = $ton . " " . $geschlecht[2];
    $ch = '';
    if (is_array($input_chord) == true)
    {
        if (in_array($wert, $input_chord))
        {
            $ch = " checked=\"checked\"";
        }
    }
    echo "<span style=\"width:120px;display:block;float:left;\"><input type=\"checkbox\" name=\"akkord[".$wert."]\" value=\"" . $wert . "\"" . $ch . "> " . $wert . " </span> ";
    $i ++;
    if ($i % 3 == 0)
    {
        echo "";
    }


}

?>
</div></div>

<br /> <br />

<div class="col-md-4 col-md-offset-4"><input type='submit' class='btn btn-block btn-lg btn-theme' value='Tonart bestimmen'/></div></form>

为什么浏览器只能使用最后一个复选框“verminderte Akkorde”?

所有复选框的代码完全相同。

感谢您的帮助!

【问题讨论】:

  • 请用开发者术语解释“工作”。究竟发生了什么,或没有发生?
  • 您不能选中第一个复选框。只有最后一个是可选的。
  • 据我所知,您正在创建大量它们,但都具有相同的名称 - akkord[]。尝试在 [] 数组部分中添加一些内容,以使每个复选框的名称不同。
  • 您能否重新格式化您的代码,使其不包含 &gt; 针脚?
  • 改成&lt;span style=\"width:120px;display:block;float:left;\"&gt;&lt;input type=\"checkbox\" name=\"akkord[".$wert."]\" value=\"" . $wert . "\"" . $ch . "&gt; " . $wert . " &lt;/span&gt; ";还是不行。

标签: php android html


【解决方案1】:

位置有问题

我所做的是删除"width:120px;display:block;float:left; 并使用col-md-4 制作每个跨度

喜欢

<div class="row">
 <div class="col-md-4">
   <span style=""><input type="checkbox" name="akkord[]" value="C dur"> C 
     dur </span>
 </div>
<div class="col-md-4">
   <span style=""><input type="checkbox" name="akkord[]" value="Cis dur"> 
     Cis dur </span>
  </div>
<div class="col-md-4">
        <span style=""><input type="checkbox" name="akkord[]" value="Des 
       dur"> Des dur </span>
</div>
</div>

否则

只需删除 span 上的样式属性并添加响应类来固定宽度和位置

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-29
    • 1970-01-01
    • 2016-02-15
    • 1970-01-01
    • 2014-09-19
    • 1970-01-01
    • 1970-01-01
    • 2023-02-24
    相关资源
    最近更新 更多