ajax - CI and GroceryCRUD DB update row -
i utilize ci 2.1 , grocerycrud 1.3.3, utilize 2 function in controller admin, cant update value of row wher have 2 values 0/1: bolean view side click on link or ajax (prefered)
function programs_management() { if($this->input->get("enable_recomandation")) { // $this->programs_management->recomandation((int)$this->input->get("programs"), ($this->input->get("recomandation")=="1")?"1":"0"); $data_for_update = array( 'recomandation' => ($this->input->get("recomandation")=="1")?"1":"0", ); $this->db->update('programs',$data_for_update,array('program_id' => $this->input->get("programs"))); } } function enable_recomandation($value, $row = null) { // or ajax solution need // homecoming "<form action='' method='post'> // <input onclick='document.getelementbyid('row').value=this.value' type='radio' name='recom' value='activ'>activ<br> // <input onclick='document.getelementbyid('row').value=this.value' type='radio' name='recom' value='inactiv'>inactiv // </form>"; if($value=="1") homecoming '<a href="'.base_url().'/admin/programs_management/?recomandation=0&program_id='.$row->program_id.'" >active</a>'; else homecoming '<a href="'.base_url().'/admin/programs_management/?recomandation=1&program_id='.$row->program_id.'" >inactive</a>'; }
or can help alternative, how ajax ?
function programs_management() { if ($this->input->get("recomandation")) { // $this->programs_management->recomandation((int)$this->input->get("programs"), ($this->input->get("recomandation")=="1")?"1":"0"); $data_for_update = array( 'recomandation' => ($this->input->get("recomandation") == "y") ? "1" : "0", ); $this->db->update('programs', $data_for_update, array('program_id' => $this->input->get("program_id"))); } } function enable_recomandation($value, $row = null) { if ($value == "1") homecoming '<a href="' . base_url() . 'admin/programs_management/?recomandation=n&program_id=' . $row->program_id . '" >active</a>'; else homecoming '<a href="' . base_url() . 'admin/programs_management/?recomandation=y&program_id=' . $row->program_id . '" >inactive</a>'; }
ajax controller updates grocery-crud
No comments:
Post a Comment