1

我有一个这样的复选框翻转开关:

<form>
  <input type="text" name="control_name[]"/>
  <label for="flip-checkbox-4">Flip toggle switch checkbox:</label>
  <input type="checkbox" data-role="flipswitch" name="control_name_switch[]" id="flip-checkbox-4" checked=""/>
</form>

使用此 php 代码读取表单:

if (!empty($_POST)) {
  $controlname = $_POST['control_name'];
  $controlstate = $_POST['control_name_switch'];
  $program = $_POST['program'];
  $i = 0;
  $ctrlSize = sizeof($controlname);
  for ($i = 0; $i < $ctrlSize; $i++) {
    if (empty($_POST['control_name_switch'])) {
        $controlstate[$i] = "&nbsp;";
    } else {
        $controlstate[$i] = "checked";
    }
  }

当我在 php 中阅读帖子时,即使我点击它并关闭它,我也会让它始终“打开”。请帮忙。

4

0 回答 0