weihphp4.0 thinkphp html checkbox的默认选中

网友投稿 786 2022-08-23

weihphp4.0 thinkphp html checkbox的默认选中

weihphp4.0 thinkphp html checkbox的默认选中

感想

最近在用weiphp4.0做开发,然后需要做增添和修改操作,我们就需要使用checkbox这种东西,然后就会出现一系列的问题,我这里做了一个beginers的示例。

ExampleController.class.php里面的代码示例:

$department_model=M('ccnu_department');$departments = $department_model->field('id,name')->where("token='".$token."'" )->select();foreach($departments as &$depart){ if(in_array($depart['id'],$data['departments']) ){ $depart['checked']=1; //设置默认选中 }else{ $depart['checked']=0; //设置默认不选中 }}$this->assign ( 'departments', $departments);

edit.html里面的示例代码:

checked="checked" >{$de.name}

核心是添加一个if语句就行了哈。

参考文献

[1].php中的checkbox如何默认选中?看别人的回答看不懂. ​​https://zhidao.baidu.com/question/179268890466842724.html​​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:[leetcode] 313. Super Ugly Number
下一篇:Ubuntu 16.04 截图软件,能够编辑截图的软件安装
相关文章

 发表评论

暂时没有评论,来抢沙发吧~