根据第一个下拉列表的选择,我根据第一个dropdownid值绑定另一个下拉值。我的问题是我给出了默认的第一个下拉值为“select”但是在第二个下拉列表中没有id值来获取值.if用户在frist下拉列表中选择“select”我需要在第二次下拉列表中加载所有值。请告诉我如何实现这一点?
答案 0 :(得分:0)
如果您将默认的第一个下拉值设为“select”,则表示此时禁用第二个下拉值。如果'country'
值等于'select'
,则表示当时禁用'state drop down'
。当我们点击该国家/地区'select'时,也会调用该禁用下拉功能。
例如HTML视图页面,显示国家/地区下拉列表。从那里你将获得国家ID。
$countryID=> From your MVC code you have pass default country ID (default ID)
$countrySelected=$this->getCountryFromName(trim($countryID']));
if ($countrySelected!= ''){
$sVal=$this->getStateList($countrySelected);
$newStateList=array('0'=>'State');
$newStateList+=$this->formatDropdownArray($sVal,'STATE_ID','NAME');
$stateSelected='State';
echo CHtml::dropDownList('STATE_IDD',$stateSelected,$newStateList,array('tabindex'=>9));
}else{
$stateSelected=$defaultState;
echo CHtml::dropDownList('STATE_IDD',$stateSelected,$stateList,array('tabindex'=>9));
}