문제

I have three dropdown lists which are dependent on each other. I want to be able to set the third DD to null whenever the first dropdown is chosen but so far my script is not doing anything. It's updating the second DD but not the third.

When all DD's are set and I update the 1st DD, it updates the 2nd but does not set the 3rd to null.

Here is my script:

echo CHtml::dropDownList('island_id',$island,$locationsList, 
          array('ajax'=>array('type'=>'POST',
                'url'=>CController::createUrl('supplierHead/getRegions'),
                'update'=>'#region_id',),
                'id'=>'island_id',
                'empty'=>'Choose Island',
                'onchange'=>'$("#province_id").html("<option value=''>Choose Province</option>")'
     )); 
echo " ";
echo CHtml::dropDownList('region_id',$region, $regionsList, 
          array('ajax'=>array('type'=>'POST',
                'url'=>CController::createUrl('supplierHead/getProvinces'),
                'update'=>'#province_id',),
                'id'=>'region_id',
                'empty'=>'Choose Region',
     ));
echo " ";
echo CHtml::dropDownList('province_id',$province,$provincesList, array('empty'=>'Choose Province'));

올바른 솔루션이 없습니다

다른 팁

Try this:

echo CHtml::dropDownList('island_id',$island,$locationsList, 
          array('ajax'=>array('type'=>'POST',
                'url'=>CController::createUrl('supplierHead/getRegions'),
                'update'=>'#region_id',),
                'id'=>'island_id',
                'empty'=>'Choose Island',
                'onchange'=>'$("#province_id,#region_id").children().html("<option value=''>Choose Province/region</option>")'
     )); 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top