Disable or enable a dropdown list
- Single Page
Posted 20 October 2012 - 13:13 PM
Is there an easy way to do that ?
Posted 26 October 2012 - 16:47 PM
Posted 27 October 2012 - 12:00 PM
Henri72 and welcome to the forum .
//it's controller's code
$crud = new grocery_CRUD();
$crud->set_table('videos');
$crud->set_relation('videos_parent','videos_groups','title');
// field "check" is checkbox which will show/hide dropdown
$f=array('check','videos_parent','file_name','videos_title');
$crud->add_fields($f);
$crud->edit_fields($f);
$crud->callback_edit_field('check',array($this,'callback_check'));
$output = $crud->render();
the callback funciton returns a checkbox and javascript code
function callback_check()
{
return '
<script type="text/javascript">
$(document).ready(function(){
$("#ch").click(function(){
if ($("#ch").is(":checked")==false){
$("#videos_parent_field_box").hide(200);
}else{
$("#videos_parent_field_box").show("");
}
})
})
</script>
<input type="checkbox" name="ch" id="ch" />';
}
Posted 27 October 2012 - 13:12 PM
Posted 14 August 2014 - 11:36 AM
Dear victor,
Thank you for this! It helped me a lot :)
Other topic, can I create a dynamic $where condition for the set_relation_n_n? I needed my set_relation_n_n to be dependent on a drop down so I was thinking of a way to make my $where condition to be dynamic... Can u help me? I did my research but I still cannot get it right...
Thanks in advance!