lundi 17 mai 2021

Custom Checkbox - Toggle (Not working at all?)


    $results = DB::query("SELECT * FROM tblDevices");
foreach($results as $row) {
  echo "<tr>";
  echo "<td>" . "" . $row['DeviceName'] . "</td>";
  echo "<td>" . "" . $row['DeviceArea'] . "</td>";
  echo "<td>" ."" . $row['DeviceType'] . "</td>";
  //echo "<td>" . "<span id='device" . $row['DeviceID'] . "'> " . $row['DeviceState'] . "</span></td>";
  echo "<td>" . "<input  id='stateToggle" . $row['DeviceID'] . "'type='checkbox' class='custom-control-input'";
  if ($row['DeviceState'] == 1)
  {
      echo " checked ";
  }
 echo "onclick='turnOn(\"" . $row['DeviceID'] . "\")' name='DeviceToggle'>";
  echo "</td>" . "</tr></tbody>";
}

I can't figure out why my toggle isn't showing up at all in the table. If I remove the class the makes it into a toggle it works fine as a checkbox (running the function etc.)

https://www.bootstraptoggle.com/#:~:text=%20Bootstrap%20Toggle%20%201%20Getting%20Started.%20You,events%20from%20the...%205%20Demos.%20%20More%20

I used the above website as another attempt, it shows the toggle but doesn't run the function at all

<input type="checkbox" checked data-toggle="toggle">

Any help would be appreciated




Aucun commentaire:

Enregistrer un commentaire