这可能是一个奇怪的问题,但我一直试图在codeigniter中反映db中的切换按钮,但它不起作用。在另一个页面中选择切换按钮。这是其在第一页上的选择方式:
<td>
<label class="switch m-r-40">
<input type="checkbox" class="switch-input" id="<?php echo $rows['applicationKey']?>" data-mail="<?php echo $rows['email']; ?>" data-confirm="<?php echo $rows['applicationId']; ?>" id="check" name="check" <?php echo $rows['status'] ? 'checked':''; ?> >
<span class="switch-label" data-on="yes" data-off="no"></span>
<span class="switch-handle"></span>
</label>
</td>
js
<script type="application/javascript">
$(function()
{
$('input[type="checkbox"]').change(function(){
//alert('shoe');
//var id=$(this).attr('id');
var appid = $(this).data('confirm');
var value=$(this).prop('checked');
if ($(this).prop('checked')){
// do something
$.post("<?php echo base_url(); ?>employer/view/accept", {check: appid, checked: 1}, function(result){
//$("span").html(result);
});
}
else
{
//
$.post("<?php echo base_url(); ?>employer/view/accept", {check: appid, checked: 0}, function(result){
//$("span").html(result);
});
}
});
});
</script>
我尝试在此处从db中提取数据并将其反映在其他页面中:
$page['applications'] = $this->db->query("SELECT a.*, b.postingName, b.`postDescription`, b.`state` FROM applications AS a INNER JOIN jobposting AS b ON a.`jobPostingKey`=b.`jobPostingKey` WHERE a.applicantKey = '$user'")->result_array();
html
<td>
<label class="switch m-r-40">
<input type="checkbox" class="switch-input" id="check" name="check" <?php echo $rows['status'] ? 'checked':''; ?> disabled="true">
<span class="switch-label" data-on="yes" data-off="no"></span>
<span class="switch-handle"></span>
</label>
</td>
答案 0 :(得分:0)
确保您具有正确的数据类型。 字符串的真值与布尔真值不同!!!
<?php
$rows['status'] = false;
?>
<td>
<label class="switch m-r-40">
<input type="checkbox" class="switch-input" id="check" name="check" <?php echo
$rows['status'] ? 'checked':''; ?> disabled="true">
<span class="switch-label" data-on="yes" data-off="no"></span>
<span class="switch-handle"></span>
</label>
</td>
<hr />
<?php
$rows['status'] = "false";
?>
<td>
<label class="switch m-r-40">
<input type="checkbox" class="switch-input" id="check" name="check" <?php echo
$rows['status'] ? 'checked':''; ?> disabled="true">
<span class="switch-label" data-on="yes" data-off="no"></span>
<span class="switch-handle"></span>
</label>
</td>