第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

類(lèi)別與每個(gè)類(lèi)別的兼容性,帶有代碼符號(hào)中的復(fù)選框

類(lèi)別與每個(gè)類(lèi)別的兼容性,帶有代碼符號(hào)中的復(fù)選框

PHP
SMILET 2022-09-03 15:51:57
我有一類(lèi)化學(xué)品,需要檢查每類(lèi)化學(xué)品與自我和他人的兼容性。帶有復(fù)選框的循環(huán)內(nèi)的循環(huán)。1. 無(wú)法通過(guò)javascript點(diǎn)擊隱藏元素時(shí)設(shè)置值;2.我如何繼續(xù)和優(yōu)化,因?yàn)?4個(gè)類(lèi)別的數(shù)據(jù)高達(dá)14000 +奇數(shù)條目。3. 建議使用逗號(hào)分隔值或單個(gè)條目?4. 如何編輯記錄并保持復(fù)選框選中時(shí)從同一頁(yè)面上的數(shù)據(jù)庫(kù)表中提取數(shù)據(jù)代碼如下:控制器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>                           
查看完整描述

2 回答

?
斯蒂芬大帝

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊

將復(fù)選框值存儲(chǔ)在具有唯一ID的單獨(dú)表中,將復(fù)選框中的id值設(shè)置為值,并將字段名稱(chēng)顯示為標(biāo)簽

因?yàn)閷?lái)在某些情況下必須更改復(fù)選框名稱(chēng),以便可以輕松更改該特定 ID 行數(shù)據(jù)。當(dāng)您嘗試使用逗號(hào)分隔符保存時(shí),這是不可能的。


查看完整回答
反對(duì) 回復(fù) 2022-09-03
?
泛舟湖上清波郎朗

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超3個(gè)贊

在這里,我找到了一種方法來(lái)做到這一點(diǎn)。希望它能幫助別人。謝謝


控制器


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->input->post();

    for($z=0;$z<count($post['category']);$z++){

        $sub_cat = "";

        foreach($this->input->post('catcat'. $z) as $values){

            $sub_cat .= $values.",";

        }

        $exp = explode(",",$sub_cat);

        $newexp = array_unique($exp);

        $newexp = implode($newexp, ',');

        $insertdata = array(

            'category'          => $post['category'][$z],

            'category_compact'  => $newexp,

        );

        $this->db->where('category',$post['category'][$z]);

        $exist = $this->db->get('tbl_compactibility_master');

        $exist = $exist->num_rows();

        if($exist == 0){

            $this->db->insert('tbl_compactibility_master',$insertdata);

        }else{

            $this->db->where('category',$post['category'][$z]);

            $this->db->update('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 $cc=0; 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>                           

            <td>

            <div class="row">

                <?php foreach($category as $key => $cat_res){ $get_single = $this->admin_model->get_single_record_compactibility($cat_results->id);?>

                <div class="col-md-6">

                    <div class="form-check-inline">

                        <label class="form-check-label">

                        <input type="checkbox" class="form-check-input my-2 checkedme" name="catcat<?=$cc;?>[]" value="<?=$cat_res->id;?>" <?php if($cat_results->id == $cat_res->id){ ?> checked="checked" <?php } ?> <?php if(in_array($cat_res->id,$get_single)){ ?>checked="checked"<?php } ?> data-forcheck="<?=$cat_results->id;?>">

                         <label class="form-check-label"><?=$cat_res->category_name;?></label>

                    </div>

                </div>

                <?php } ?>

              </div>

           </td>

       </tr>

       <?php $cc++; } ?>

   </table>

   <div class="row">

       <div class="col-md-4">

           <div class="form-group">

              <button class="btn btn-primary btn-sm my-4" id="submit_button" type="submit">Save Data</button>

            </div>

        </div>

    </div>

</form>

函數(shù) get_single_record_compactibility()


public function get_single_record_compactibility($cat){

    $this->db->where('category',$cat);

    $result = $this->db->get('tbl_compactibility_master');

    $result = $result->row();

    if(!empty($result)){

        return explode(",",$result->category_compact);

    }else{

        return array();

    }

}

腳本


$('.checkedme').on("click",function() {

    var getVal = $(this).val();

    var test = $(this).data('forcheck');

    $('#company_form').find("input[data-forcheck='"+getVal+"'][value='"+test+"']").prop('checked',this.checked);

});


查看完整回答
反對(duì) 回復(fù) 2022-09-03
  • 2 回答
  • 0 關(guān)注
  • 96 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)