php - how to pass multiple values onchange event of <select> in codeigniter -


i want show student selected school, class , section. if delete 'class_id' => $class_id, 'section_id' => $section_id, controller show student selected school otherwise show nothing. solution please. wrong ? file have select value

    <div class="form-group">                         <label class="col-sm-3 control-label" >school<span class="required">*</span></label>                                            <div class="col-sm-5">                                                <select name="school_id" id="school_id" class="js-example-basic-multiple form-control" onchange="get_student_by_school_class_section_id()">                                             <option value="" >select school...</option>                                                                               <?php if (!empty($all_school_info)): foreach ($all_school_info $v_school): ?>                                                     <option value="<?php echo $v_school->school_id; ?>"                                                     <?php if (!empty($all_student_complain_info->school_id)) {                                                          echo $v_school->school_id == $all_student_complain_info->school_id ? 'selected ' : ''; } ?>>                                                                  <?php echo $v_school->school_name ; ?>                                                     </option>                                                     <?php                                                 endforeach;                                             endif;                                             ?>                                          </select>                                               </div>                                             </div>                                                <div class="form-group">                         <label class="col-sm-3 control-label" >class<span class="required">*</span></label>                                            <div class="col-sm-5">                                                <select name="class_id" id="class_id" class="js-example-basic-multiple form-control" onchange="get_student_by_school_class_section_id()">                                             <option value="" >select class...</option>                                                                               <?php if (!empty($all_classes_info)): foreach ($all_classes_info $v_class): ?>                                                     <option value="<?php echo $v_class->class_id; ?>"                                                     <?php if (!empty($all_student_complain_info->class_id)) {                                                          echo $v_class->class_id == $all_student_complain_info->class_id ? 'selected ' : ''; } ?>>                                                                  <?php echo $v_class->classes_name ; ?>                                                     </option>                                                     <?php                                                 endforeach;                                             endif;                                             ?>                                          </select>                                               </div>                                             </div>                                              <div class="form-group">                         <label class="col-sm-3 control-label" >section<span class="required">*</span></label>                                            <div class="col-sm-5">                                                <select name="section_id" id="section_id" class="js-example-basic-multiple form-control" onchange="get_student_by_school_class_section_id()">                                             <option value="" >select section...</option>                                                                               <?php if (!empty($all_section_info)): foreach ($all_section_info $v_section): ?>                                                     <option value="<?php echo $v_section->section_id; ?>"                                                     <?php if (!empty($all_student_complain_info->section_id)) {                                                          echo $v_section->section_id == $all_student_complain_info->section_id ? 'selected ' : ''; } ?>>                                                                  <?php echo $v_section->section_name ; ?>                                                     </option>                                                     <?php                                                 endforeach;                                             endif;                                             ?>                                          </select>                                               </div>                                             </div> <div class="form-group">                 <label class="col-sm-3 control-label" >student<span class="required">*</span></label>                                    <div class="col-sm-5">                                        <select name="student_id" id="student" class="js-example-basic-multiple form-control" >                                     <option value="" >select student...</option>                                                                       <?php if (!empty($student_info)): foreach ($student_info $v_student): ?>                                             <option value="<?php echo $v_student->student_id; ?>"                                             <?php if (!empty($all_student_complain_info->student_id)) {                                                  echo $v_student->student_id == $all_student_complain_info->student_id ? 'selected ' : ''; } ?>>                                                          <?php echo $v_student->student_id.'&nbsp;&nbsp;'.$v_student->student_name.'&nbsp;('.$v_student->student_father_name.')' ; ?>                                             </option>                                             <?php                                         endforeach;                                     endif;                                     ?>                                  </select>                                       </div>                                     </div> 

this ajax.php

function get_student_by_school_class_section_id() {      var school_id = document.getelementbyid('school_id').value;      var class_id = document.getelementbyid('class_id').value;      var section_id = document.getelementbyid('section_id').value;         var base_url = '<?= base_url() ?>';         var strurl = base_url + "admin/global_controller/get_student_by_school_class_section_id/" + school_id + "/" + class_id + "/" + section_id;         var req = getxmlhttp();         if (req) {             req.onreadystatechange = function() {                 if (req.readystate == 4) {                     // if "ok"                     if (req.status == 200) {                         var result = req.responsetext;                          $("#student").html("<option value='' >select student...</option>");                         $("#student").append(result);                      } else {                         alert("there problem while using xmlhttp:\n" + req.statustext);                     }                 }             }             req.open("post", strurl, true);             req.send(null);         }      } 

this controller.php

public function get_student_by_school_class_section_id($school_id, $class_id, $section_id) {         $html = null;         $this->studentrecord_model->_table_name = 'tbl_studentrecords';         $this->studentrecord_model->_order_by = 'student_id';         $student_info = $this->studentrecord_model->get_by(array('school_id' => $school_id, 'class_id' => $class_id, 'section_id' => $section_id, 'status' => '1'), false);         if (!empty($student_info)) {             foreach ($student_info $v_student_info) {                 $html.="<option value='" . $v_student_info->student_id . "'>" .$v_student_info->student_id.'&nbsp;'.$v_student_info->student_name.'&nbsp;('.$v_student_info->student_father_name.')'. "</option>";             }         }         echo $html;     } 

i want show student selected school, class , section. if delete 'class_id' => $class_id, 'section_id' => $section_id, controller show student selected school otherwise show nothing. solution please. wrong ?

this studentrecord_model.php

public function all_student_record_info_by_scs($school_id, $class_id, $section_id) {         $this->db->select('tbl_studentrecords.*', false);         $this->db->select('tbl_school.*', false);         $this->db->select('tbl_class.*', false);         $this->db->select('tbl_section.*', false);         $this->db->select('tbl_fee_department.*', false);         $this->db->from('tbl_studentrecords');         $this->db->join('tbl_school', 'tbl_school.school_id = tbl_studentrecords.school_id', 'left');         $this->db->join('tbl_class', 'tbl_class.class_id = tbl_studentrecords.class_id', 'left');         $this->db->join('tbl_section', 'tbl_section.section_id = tbl_studentrecords.section_id', 'left');         $this->db->join('tbl_fee_department', 'tbl_fee_department.fee_department_id = tbl_studentrecords.fee_department_id', 'left');         $this->db->where('tbl_studentrecords.school_id', $school_id);         $this->db->where('tbl_studentrecords.class_id', $class_id);         $this->db->where('tbl_studentrecords.section_id', $section_id);         $query_result = $this->db->get();         $result = $query_result->result();         return $result;     } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -