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