代码点火器下拉顺序,第一个下拉列表中选择的值musn';第二天中午


codeigniter dropdown order, value chosen on first dropdown musn't apear on 2nd one

我需要在健身房中设置一个四顺序的运动选择,所以我必须使用四个下拉列表,我必须从数据库中检索数据列表,这是一个包含30个学科的数组drom数据库,当我在第一个下拉列表中选择第一个时,第二个下拉列表必须不包含这个值,而且当我从第三个下拉列表中选择一个值时,这个下拉列表必须不包含下拉列表1和下拉列表2中的值1和值2,关于下拉列表4,它必须只包含数据库中的27个值

我的型号:participantsport_m.php:

  public function get_new()
{
$participant_sport = new stdClass();
$participant_sport->nom = '';
$participant_sport->prenom = '';
$participant_sport->trimestres = '';
$participant_sport->sport_ordre1 = '';
$participant_sport->sport_ordre2 = '';
$participant_sport->sport_ordre3 = '';
$participant_sport->sport_ordre4 = '';
$participant_sport->sport_montant_paye = '';
$participant_sport->sport_debut_periode = '';
$participant_sport->sport_fin_periode = '';
  return $participant_sport;
}

    function get_discipline_sport() {
            $this ->db->select('id, nom_discipline');
            $query = $this ->db->get('disciplines_sport');
            $salles = array();
            if ($query->result()) {
                    foreach ($query->result() as $discipline) {
                      $disciplines[$discipline->id] = $discipline->nom_discipline;
                    }
                    return $disciplines;
            } else {
                    return FALSE;
            }
    }

数据库结构:id-nom_discipline-tarif_procipline-描述

我的控制器代理.php:

        public function inscriresport ($id = NULL)
        {
            // Fetch a participant or set a new one
            if ($id) {
                $this->data['participant_sport'] = $this->participantsport_m->get($id);
                count($this->data['participant_sport']) || $this->data['errors'][] = 'Agent non trouvé';
            // explode to array
            // print_r($this->data['participant_sport']['trimestres[]']); // test before explode
              $this->data['participant_sport']->trimestres = explode(",", $this->data['participant_sport']->trimestres);
            // print_r($this->data['participant_sport']['trimestres[]']); // test after explode
            }
            else {
                $this->data['participant_sport'] = $this->participantsport_m->get_new();
            }
            // Set up the form
            $rules = $this->participantsport_m->rules_participantsport;
            $this->form_validation->set_rules($rules);
            // Process the form
            if ($this->form_validation->run() == TRUE) {
                $data = $this->participantsport_m->array_from_post(array('nom', 'prenom', 'beneficiaire', 'trimestres' , 'sport_ordre1', 'sport_ordre2', 'sport_ordre3', 'sport_ordre3',  ,'sport_montant_paye', 'sport_debut_periode', 'sport_fin_periode'));
                $this->participantsport_m->save($data, $id);
                redirect('admin/agent/profile/3608');
            }
            // Load the view
            $this->data['subview'] = 'admin/agent/inscriresport';
            $this->load->view('admin/_layout_main', $this->data);
       }

而我的观点insiresport.php:

                    <div class="widget-box">
                        <div class="widget-title">
                            <span class="icon">
                                <i class="icon-align-justify"></i>                                  
                            </span>
                            <h5><?php echo empty($participant->id) ? 'Nouveau Agent OCP:' : 'Modification de: ' . $participant_sport->nom.' '.$participant_sport->prenom; ?></h5>
                        </div>
                        <div class="widget-content nopadding">
                            <?php echo form_open(); ?>

                  <div  <?php if(form_error('nom')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?>>
                    <label class="control-label">Nom :</label>
                    <div class="controls">
                       <?php echo form_input('nom', set_value('nom', $this->input->get('nom') )); ?>
                       <span class="help-inline"><?php echo form_error('nom'); ?></span>
                    </div>
                  </div>

                  <div  <?php if(form_error('prenom')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?>>
                    <label class="control-label">Prenom :</label>
                    <div class="controls">
                       <?php echo form_input('prenom', set_value('prenom', $this->input->get('prenom') )); ?>
                       <span class="help-inline"><?php echo form_error('prenom'); ?></span>
                    </div>
                  </div>


                        <div  <?php if(form_error('beneficiaire')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?>>
                          <label class="control-label">Bénéficiaire :</label>
                          <div class="controls">
                                                  <label><?php echo form_radio('beneficiaire', 'Agent', $this->input->get('beneficiaire') == 'Agent') ?> Agent </label>
                                                  <label><?php echo form_radio('beneficiaire', 'Conjoint', $this->input->get('beneficiaire')  == 'Conjoint') ?> Conjoint </label>
                                                  <label><?php echo form_radio('beneficiaire', 'Enfant', $this->input->get('beneficiaire')  == 'Enfant') ?> Enfant </label>
                                                  <span class="help-inline"><?php echo form_error('beneficiaire'); ?></span>
                          </div>
                        </div>


              <div <?php if(form_error('trimestres[]')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?> >
                      <label class="control-label">Trimestres :</label>
                      <div class="controls" >
                      <?php $options = array(
                                          'trim1'  => ' Premier trimestre (Janv,Fév,Mars)',
                                          'trim2'    => ' Deuxiéme trimestre (Avril,Mai,Juin)',
                                          'trim3'   => ' Troisiéme trimestre (Juill,Aout,Sept)',
                                          'trim4' => ' Quatriéme trimestre (Oct,Nov,Déc)',
                                        );
                     echo form_multiselect('trimestres[]', $options , $this->input->post('trimestres') ? $this->input->post('trimestres') : $participant_sport->trimestres, 'id="trim"'); ?>
                      <span class="help-inline"><?php echo form_error('trimestres[]'); ?></span>
                  </div>
              </div>

              <div <?php if(form_error('sport_ordre1')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?> >
                      <label class="control-label">Nom de la Salle :</label>
                      <div class="controls">
                      <?php echo form_dropdown('sport_ordre1', $countries , $this->input->post('sport_ordre1') ? $this->input->post('sport_ordre1') : $participant_salle->sport_ordre1 , 'id="ordre1"'); ?>
                      <span class="help-inline"><?php echo form_error('sport_ordre1'); ?></span>
                  </div>
              </div>
              <div <?php if(form_error('sport_ordre2')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?> >
                      <label class="control-label">Nom de la Salle :</label>
                      <div class="controls">
                      <?php echo form_dropdown('sport_ordre2', $countries , $this->input->post('sport_ordre2') ? $this->input->post('sport_ordre2') : $participant_salle->sport_ordre2 , 'id="ordre2"'); ?>
                      <span class="help-inline"><?php echo form_error('sport_ordre2'); ?></span>
                  </div>
              </div>
              <div <?php if(form_error('sport_ordre3')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?> >
                      <label class="control-label">Nom de la Salle :</label>
                      <div class="controls">
                      <?php echo form_dropdown('sport_ordre3', $countries , $this->input->post('sport_ordre3') ? $this->input->post('sport_ordre3') : $participant_salle->sport_ordre3 , 'id="ordre3"'); ?>
                      <span class="help-inline"><?php echo form_error('sport_ordre3'); ?></span>
                  </div>
              </div>
              <div <?php if(form_error('sport_ordre4')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?> >
                      <label class="control-label">Nom de la Salle :</label>
                      <div class="controls">
                      <?php echo form_dropdown('sport_ordre4', $countries , $this->input->post('sport_ordre4') ? $this->input->post('sport_ordre4') : $participant_salle->sport_ordre4 , 'id="ordre4"'); ?>
                      <span class="help-inline"><?php echo form_error('sport_ordre4'); ?></span>
                  </div>
              </div>


                        <div  <?php if(form_error('sport_montant_paye')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?>>
                          <label class="control-label">Montant à payé :</label>
                          <div class="controls">
                             <?php echo form_input('sport_montant_paye', set_value('sport_montant_paye', $participant_sport->sport_montant_paye)); ?>
                             <span class="help-inline"><?php echo form_error('sport_montant_paye'); ?></span>
                          </div>
                        </div>



                        <div  <?php if(form_error('sport_debut_periode')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?>>
                          <label class="control-label">Debut période :</label>
                          <div class="controls">
                             <input type="text" name="sport_debut_periode" id="date3" value="<?php echo set_value('sport_debut_periode', $participant_sport->sport_debut_periode) ?>" />
                             <span class="help-inline"><?php echo form_error('sport_debut_periode'); ?></span>
                          </div>
                        </div>


                        <div  <?php if(form_error('sport_fin_periode')) { echo 'class="control-group error"'; } else {echo 'class="control-group"';} ?>>
                          <label class="control-label">Fin période :</label>
                          <div class="controls">
                             <input type="text" name="sport_fin_periode" id="date4" value="<?php echo set_value('sport_fin_periode', $participant_sport->sport_fin_periode) ?>" />
                             <span class="help-inline"><?php echo form_error('sport_fin_periode'); ?></span>
                          </div>
                        </div>



                                <div class="form-actions">
                                    <?php echo form_submit('submit', 'Enregistrer', 'class="btn btn-success"'); ?>
                                </div>
                            <?php echo form_close();?>
                        </div>
                    </div>
                </br>

我需要如何通过javascript来做到这一点,我是javascript的新手,我不知道从哪里开始,有什么帮助吗?非常感谢。

我建议在所有下拉列表中包括所有体育项目,当你想提交表格时,去检查是否有相同价值的下拉列表。你可以用获得它们

var flag = false;
var e1 = document.getElementById("dropdown1 id");
var value1 = e1.options[e1.selectedIndex].value;
var e2 = document.getElementById("dropdown2 id");
var value2 = e2.options[e2.selectedIndex].value;
...
if(value1 != value2 && ...)
{
  flag = true;
}
if(flag)
{
  // Stuff
}