Yii implementation of cascading drop-down menu method, yii Implementation drop-down menu
In this paper, the method of implementing the cascading drop-down menu of Yii is described in detail in the following steps:
1. Add the following code to the template:
' id ' = ' task-shop-id ',))?>
In this code, ordersrc_options () reads a drop-down menu first. Call the options method in the ORDERSCR model. The contents are as follows
public static function Options ($hasShop = True) {$model = new self (); if ($hasShop) $model->hasshop (); $models = $model ->findall (); $array = Array (' = ' = ' all '); foreach ($models as $model) {$array [$model->src_id] = $model->src_name;} return $array;}
2. Then add the JS code to the template page to make the content assignment to the second drop-down menu when the first drop-down menu changes.
In this JS code, the implementation calls a program to get the value of the second drop-down menu (call the Actiongetshops method in the controller), any append to the second drop-down menu.
The Actiongetshops method in the controller is as follows:
Public Function Actiongetshops () {$srcId = $_get[' srcid '); $array = Thirdpartinterfaceconfig::options ($srcId); $ Htmlcontent = "All "; foreach ($array as $k = = $v) {$htmlContent. = "{$v} "; } Echo $htmlContent;}
Yii framework, how to use the drop-down menu to filter
Use Ajax to send the selected data to the controller and get the results displayed on the view
Yii How to do pull-down menu, not linkage level two, that is, such as I want to send e-mail to others, you can have a drop-down menu casually choose who to send
Use Ajax to trigger the OnChange event submission.
http://www.bkjia.com/PHPjc/854353.html www.bkjia.com true http://www.bkjia.com/PHPjc/854353.html techarticle YII implements the Cascade drop-down menu method, Yii implements the drop-down menu This article describes in detail the yii implementation of the cascading drop-down menu method, the following steps: 1. Add the following code to the template: PHP EC ...