Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 检索开/关开关的值_Php_Html_Css_Api - Fatal编程技术网

Php 检索开/关开关的值

Php 检索开/关开关的值,php,html,css,api,Php,Html,Css,Api,我对web开发和API还不熟悉,所以请原谅我。所以我有开/关按钮开关,我不确定如何根据返回的值使开关默认为开或关。值为1表示真,0表示假 要检索该值,我需要调用,它当前正在返回值“1”,但如何在交换机中实现它,以便它能够显示从后端调用的内容 Switch.php <div class="onoffswitch"> <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoff

我对web开发和API还不熟悉,所以请原谅我。所以我有开/关按钮开关,我不确定如何根据返回的值使开关默认为开或关。值为1表示真,0表示假

要检索该值,我需要调用
,它当前正在返回值“1”,但如何在交换机中实现它,以便它能够显示从后端调用的内容

Switch.php

<div class="onoffswitch">
 <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
      <label class="onoffswitch-label" for="myonoffswitch">
         <span class="onoffswitch-inner"></span>
         <span class="onoffswitch-switch"></span>
      </label>
</div> 

您可以使onoff开关动态,如:

Swtich.php

<div class="onoffswitch">
   <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" <?php echo $resultMemberInfo['allowNotification'] == '1'?'checked':''; ?>>
   <label class="onoffswitch-label" for="myonoffswitch">
     <span class="onoffswitch-inner"></span>
     <span class="onoffswitch-switch"></span>
   </label>
</div> 

使用此$(“输入[type='checkbox']”)val();
<div class="onoffswitch">
   <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" <?php echo $resultMemberInfo['allowNotification'] == '1'?'checked':''; ?>>
   <label class="onoffswitch-label" for="myonoffswitch">
     <span class="onoffswitch-inner"></span>
     <span class="onoffswitch-switch"></span>
   </label>
</div>