您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Yii - 连动下拉菜单,可多级哦_PHP教程

2025/1/5 6:10:42发布13次查看
视图文件
[html] 
getmemgroup(),array(  
        'class'=>'s_ipt w_120',  
        'empty'=>'请选择会员组',  
        'ajax' =>array(  
                    'type'=>'get',  
                    'url'=>ccontroller::createurl('cmptemplates/getmemtype'),  
                    'update'=>'#cmptemplates_zmg_ids',  
                    'data'=>array('mid'=>js:this.value)  
                    ),  
        ))?>  
dropdownlist($model,'zmg_ids',array(),array('class'=>'s_ipt w_120','empty'=>'选择会员等级'))?>
控制器
[html]  
/**  
 * 获取会员组,对应的会员等级,用于下拉菜单  
 */  
public function actiongetmemtype($mid=0)  
 {  
    $criteria=new cdbcriteria;  
    $criteria->compare('zmg_id',$mid);  
    $memtype = memtype::model()->findall($criteria);
$name = '选择会员等级';  
    echo chtml::tag('option', array('value'=>0), $name, true);  
    foreach($memtype as $val) {  
        echo chtml::tag('option', array('value'=>$val->zmt_id),chtml::encode($val->zmt_title),true);  
    }  
}
模型
[html]  
/*  
 * 取会员组信息      
 */  
  public function getmemgroup($type=null){  
    if($type==null){  
        $criteria=new cdbcriteria;  
        $criteria->compare('type','1');  
        $memgroup = memgroup::model()->findall($criteria);  
        return chtml::listdata($memgroup,'zmg_id','zmg_title');  
    }else{  
        $level = $this->getmemgroup();  
        if(array_key_exists($type,$level)){  
            return $level[$type];  
        }  
    }  
  }
http://www.bkjia.com/phpjc/477691.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/477691.htmltecharticle视图文件 [html] ?php echo chtml::activedropdownlist($model,zmg_id,memgroup::model()-getmemgroup(),array( class=s_ipt w_120, empty=请选择会员组, ajax =array( type=get, url=...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product