php - 如何使用 php 使这个翻转开关基于 mysql 的值工作

标签 php mysql twitter-bootstrap html5-data jquery-mobile-flipswitch

我买了一个基于 bootstrap/html 的管理面板,它有很多很棒的功能,其中之一是翻转开关,它看起来非常时尚,我希望将它用于我的任何产品状态。

实际代码是这样的

<div data-off-label="Disabled"  data-on-label="Enabled"  class="switch" style="margin-top:12px;">
<input type="checkbox" checked="checked">                                       
</div>

当我检查浏览器中的元素时,我得到以下信息:

<div data-off-label="Disabled" data-on-label="Enabled" class="switch" style="margin-top:12px;">
<div class="switch-on switch-animate" style="">
    <input type="checkbox" checked="checked">
    <span class="switch-left">Enabled</span><label>&nbsp;
    </label><span class="switch-right">Disabled</span>
</div>

我使用了通常的 data-role="flipswitch"但这看起来不一样

开机是这样的

<div class="switch-on switch-animate"> 

关机是这样的

<div class="switch-off switch animate">

请帮助我如何使用上面的内容根据来自数据库的值来更改页面加载时间。

我试过跟随但没有成功

<div data-off-label="Disabled" data-on-label="Enabled" class="switch" style="margin-top:12px;">
<div class="<?if($Status = 1){ echo 'switch-on'; } else { echo 'switch-off'; } switch-animate" style="">
    <input type="checkbox" checked="checked">
    <span class="switch-left">Enabled</span><label>&nbsp;
    </label><span class="switch-right">Disabled</span>
</div>

并且switched不能正常工作,平滑停止滑动。

谢谢大家的帮助

========= 似乎管理面板的开发人员将此模块用于开关

http://www.bootstrap-switch.org/documentation-2.html

因此,如果有人可以帮助我,我将不胜感激。我现在被困了几个小时:(

最佳答案

您提供的文档显示复选框状态可以设置为父 div 上的数据属性。

<div data-state="<?php echo ($status == 1) ? 'true' : 'false' ?>" data-off-label="Disabled"  data-on-label="Enabled"  class="switch" style="margin-top:12px;">
    <input type="checkbox" checked="checked">                                       
</div>

关于php - 如何使用 php 使这个翻转开关基于 mysql 的值工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30707908/

相关文章:

php - 网页-用户自定义样式

mysql - 无论如何要在 mysql 的行中附加列数据?

php - 为什么这个简单的 "INSERT INTO"查询不起作用

php - 如何检查哪个@route触发了Symfony2中的Controller::Action?

php - pear 数据库错误 : extension not found

php - 添加带有变量引用表名称的命名约束 mysqli

html - bootstrap/sass 中的第一个和最后一个 child 不工作

javascript - 使用 BootstrapDialog.show 时禁用外部点击

twitter-bootstrap - Jumbotron 对齐问题

php文件权限,无法复制: failed to open stream