我在一頁(yè)中有兩個(gè)模態(tài)。一個(gè)用于編輯,另一個(gè)用于創(chuàng)建。在這兩個(gè)模式中都包含 select2 選項(xiàng)。以及我從數(shù)據(jù)庫(kù)中獲得的選項(xiàng)。我想將數(shù)據(jù)用于兩個(gè)模態(tài)。但是我在模態(tài)創(chuàng)建中遇到錯(cuò)誤,而模態(tài)編輯中沒有錯(cuò)誤。在模態(tài)創(chuàng)建中,它無法顯示選擇選項(xiàng)中的數(shù)據(jù)。誰能幫我?我試試這個(gè) public function detail_produk(){ $data['item']=$this->admin_model->get_all_detail_produk(); $data['ukuran'] = $this->admin_model->get_ukuran(); $data['sidebar'] = $this->load->view('sidebar','',TRUE); $data['header'] = $this->load->view('header','',TRUE); $this->load->view('detail_produk', $data);}風(fēng)景 <div class="modal fade" role="dialog" id="detail_user"><div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="form-group row"> <label class="col-sm-2 col-form-label">Ukuran</label> <div class="col-sm-10"> <select class="form-control select2" style="width: 100%;" id="ukuran"> <option selected="true" disabled="disabled">Pilih Ukuran</option> <?php foreach ($ukuran as $ukuran) { ?> <option value="<?php echo $ukuran['id'];?>"><?php echo $ukuran['size'];?></option> <?php } ?> </select> </div> </div> </form> </div><div class="modal-footer"> <button type="button" id="button-simpan" class="btn btn-primary mr-auto" >Simpan</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Kembali</button></div></div></div></div><div class="modal fade" role="dialog" id="tambah"><div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> </div>
不能在不同的模式框中使用相同的數(shù)據(jù)作為選項(xiàng)
慕標(biāo)琳琳
2023-12-11 10:18:27