YII implementation of the Cascade drop-down menu method, Yii implementation of the drop-down menu _php Tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.