0

タイトルが示すように、前の選択でロードする必要がある 3 つのドロップダウン メニューがあります。それは国 - 州 - 市に行きます。そのため、国が選択されたら、国 ID に基づいてすべての選択をロードする州メニューが必要です。そして、州が選択されたら、その州 ID をロードするすべての都市が必要です。現時点では、国が読み込まれますが、そのうちの 1 つが選択されても何も起こりません。したがって、他の 2 つのドロップダウン メニューには「-- Select State--」のみが表示され、他には何も表示されません。

これは、サイトでドロップダウンの onchange イベントを使用する一般的な方法ですが、PHP でこのようなコードを作成したことはありません。

この PHP は私が作成したものではないため、私にとっては完全に無関係です。ドロップダウンの一部であるこれまでのファイルの内容は次のとおりです。

 <div class="control-group">
                <label class="control-label"> * Country : </label>
                <div class="controls">

                    <?php echo $this->Form->input('state_field',array('type'=>'hidden','id'=>'state_field','value'=>'data[User][state_id]'));

                           echo $this->Form->input('city_field',array('type'=>'hidden','id'=>'city_field','value'=>'data[User][citie_id]'));


                              $country=$this->Html->get_country();

                           echo $this->Form->input('countrie_id',array('type'=>'select','id'=>'country_down','class'=>'input-xlarge','options'=>$country,'empty'=>'-- Select Country --','label'=>false,'selected'=>$this->data['User']['countrie_id'])); ?>

                    <span class="help-block"> Select Your Country.</span>
                </div>

        </div>

        <div class="control-group">
                <label class="control-label"> * State : </label>
                <div class="controls" id="state_box">
                    <?php

                                if($this->data['User']['countrie_id']){
                                   $state=$this->Html->get_state($this->data['User']['countrie_id']);
                                } else{
                                   $state='';
                                }
                                   echo $this->Form->input('state_id',array('type'=>'select','id'=>'state_down','class'=>'input-xlarge','options'=>$state,'empty'=>'-- Select State --','label'=>false,'selected'=>$this->data['User']['state_id']));

                           ?>
                    <span class="help-block"> Select Your State.</span>
                </div>
        </div>

         <div class="control-group">
                <label class="control-label"> * City : </label>
                <div class="controls" id="city_box">
                    <?php
                    if($this->data['User']['state_id'])
                     {
                        $citi=$this->data['User']['state_id'];

                         $cities=$this->Html->get_city($this->data['User']['state_id']);

                      }else{
                                   $cities='';
                                }
                  echo $this->Form->input('citie_id',array('type'=>'select','options'=>$cities,'empty'=>'-- Select City --','class'=>'input-xlarge','label'=>false,'selected'=>$this->data['User']['citie_id']));
                    ?>
                    <span class="help-block"> Select Your City.</span>
                </div>
        </div>
4

0 に答える 0