我有一类化学品,需要检查每类化学品与自我和他人的兼容性。带有复选框的循环内的循环。1. 无法通过javascript点击隐藏元素时设置值;2.我如何继续和优化,因为24个类别的数据高达14000 +奇数条目。3. 建议使用逗号分隔值或单个条目?4. 如何编辑记录并保持复选框选中时从同一页面上的数据库表中提取数据
代码如下:
控制器
public function compactibility_chart_master(){
$data['title'] = 'Compactibility Chart Master';
$this->form_validation->set_rules('category[]', 'Category Name','required|trim|xss_clean');
if($this->form_validation->run() === FALSE){
$data['category'] = $this->admin_model->get_all_active_entities('tbl_category');
$this->load->view('admin/compactibility_chart_master',$data);
}else{
$this->admin_model->set_compactibility_chart_master();
$this->session->set_flashdata('success','Compacitibiliy Chart Master updated Successfully');
redirect('compactibility_chart_master', 'refresh');
}
}
型
public function set_compactibility_chart_master(){
$post = $this->_array_remove_null($this->input->post());
$insertdata = array();
for($z=0;$z<count($post['cat_cat']);$z++){
foreach($post['cat_cat'] as $values){
$insertdata[] = array(
'category' => $post['category'][$z],
'category_compact' => $values,
);
}
}
$this->db->insert_batch('tbl_compactibility_master',$insertdata);
return true;
}
视图
<form name="compatibility_form" id="compatibility_form" method="post" enctype="multipart/form-data" data-parsley-validate>
<table class="table table-bordered" width="100%">
<?php if(!empty($category)){ foreach($category as $cat_results){ ?>
<tr class="data">
<th>
<button class="btn btn-primary btn-sm my-2" type="button"><?=$cat_results->category_name;?></button>
<input type="hidden" name="category[]" class="categooryclass" value="<?=$cat_results->id;?>">
</th>
斯蒂芬大帝
泛舟湖上清波郎朗