[英]CodeIgniter / GroceryCrud : radio button / drop down dependent to unhide hidden field
before i ask some question i just want to appreciate this is the best CRUD generator for CI/PHP.在我问一些问题之前,我只想感谢这是最好的 CI/PHP CRUD 生成器。 I'm using this for all of my website.
我在我所有的网站上都使用它。
so my question is, i have some fields in my controller :所以我的问题是,我的控制器中有一些字段:
$crud->display_as('id', 'No')
->display_as('name', 'Name')
->display_as('address', 'Address')
->display_as('phone', 'Phone')
->display_as('need_date', 'Need date?')
->display_as('date', 'Date');
// this is for radio button
$crud->field_type('need_date','true_false');
If the active radio button clicked will show the 'date' field如果单击的活动单选按钮将显示“日期”字段
if I clicked the inactive button it will hide again the 'date' field如果我单击非活动按钮,它将再次隐藏“日期”字段
I appreciate all the help that comes, Thank you very much我感谢所有的帮助,非常感谢
i already add this line to the view page:我已经将此行添加到视图页面:
function yesnoCheck() {
if (document.getElementById('field-needdate-yes').checked) {
document.getElementById('field-date').style.display = 'none';
}
else document.getElementById('field-date').style.display = 'block';
}
but m problem is that i need to add the yesnoCheck function to the onClick radio button, but how can i do that?但我的问题是我需要将yesnoCheck函数添加到 onClick 单选按钮,但我该怎么做?
in the end of controller try to echo this script or load it as a view,在控制器的末尾尝试回显此脚本或将其作为视图加载,
echo '<script>
document.ready(function(){
$(".field-needdate-yes:unchecked").each(function(){
document.getElementById('field-date').style.display = 'none';
});
});
</script>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.