yii实现级联下拉菜单的方法
这篇文章主要介绍了yii实现级联下拉菜单的方法,需要的朋友可以参考下
本文详细讲述了yii实现级联下拉菜单的方法,具体步骤如下:
1.模版中加入如下代码:
dropDownList($model, 'src_type_id', OrderSrc::options(), array( 'id' => 'task-order-src-id', )); echo $form->dropDownList($model, 'src_shop_id', array(''=>'全部'), array( 'id' => 'task-shop-id', )) ?>
在这段代码中,OrderSrc_options() 这个是先读取一个下拉菜单。调用OrderScr model中的options方法。内容如下
public static function options($hasShop = true) { $model = new self(); if($hasShop) $model->hasShop(); $models = $model->findAll(); $array = array(''=>'全部'); foreach($models as $model) { $array[$model->src_id] = $model->src_name; } return $array; }
2.然后在模版页面中增加JS代码,,实现当第一个下拉菜单变化时给第二个下拉菜单进行内容赋值。
在这段JS代码中,实现调取一个程序获取第二个下拉菜单的值(调用Controller中的actionGetShops方法),任何追加到第二个下拉菜单中。
Controller中的actionGetShops方法如下:
public function actionGetShops() { $srcId = $_GET['srcId']; $array = ThirdpartInterfaceConfig::options($srcId); $htmlContent = ""; } echo $htmlContent; }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to make the WPS table drop-down menu: After selecting the cell where you want to set the drop-down menu, click "Data", "Validity" in sequence, and then make the corresponding settings in the pop-up dialog box to pull down our menu. As a powerful office software, WPS has the ability to edit documents, statistical data tables, etc., which provides a lot of convenience for many people who need to deal with text, data, etc. In order to skillfully use WPS software to provide us with a lot of convenience, we need to be able to master various very basic operations of WPS software. In this article, the editor will share with you how to use WPS software. Perform drop-down menu operations in the WPS table that appears. After opening the WPS form, first select the

Are you tired of seeing the traditional black borders on your Word documents all the time? Are you looking for ways how to add some colorful and artistic borders to your documents to make them more attractive and fun? How about adding different artistic borders to different pages of your Word document? Or apply a single artistic border to all pages in the document at once? I know you’re as excited as we are about this whole artistic borders thing! Go straight to this article to learn how to successfully apply artistic borders to Word documents. Part 1: How to Apply the Same Artistic Page Border to All Pages in a Word Document Step 1: Open the Word document and click the "Design" tab in the top ribbon. Choose in DESIGN

With Microsoft Word, comments are important, especially when the document is shared among multiple people. Everyone can add something to the document content through his/her comments, and it is very important to retain these comments for future reference. But when you need to print a document, do you really need to print comments? In some cases, yes. But for some other cases, this is a big no! In this article, we explain through 2 different solutions how to easily print a Word document without printing the comments on it. Please remember that comments are only hidden and will not be deleted. Therefore, you absolutely do not risk any part of your document here by printing it without comment. Hope you like it! Solution 1: Pass

Due to recent improvements around the world, PC parts are now available at MSRP, which has prompted many users to finally build their dream PC. Building a PC can have its challenges, and one of the tasks is fitting your screen to your monitor's display. If you can't fit a screen to your monitor on Windows 11, here's everything you need to know. let's start. How to adjust your screen for monitoring on Windows 11 in 5 ways To make your screen fit your monitor, you can adjust the resolution, scaling, or display output settings based on your current settings. We recommend that you try resizing the resolution to maintain visual quality and dpi. However, if this doesn't work for you, you can try

How to Change the Transparency of an Image in Google Slides Google Slides allows you to make small changes to your images. You can use the Format Options menu in Google Slides to change the transparency level of any image you insert. To make an image transparent using the Format Options menu in Google Slides: Open your existing Google Slides presentation or create a new one. Select an existing image on one of the slides in your presentation. Alternatively, add an image by pressing Insert > Image and selecting one of the upload options. After selecting the image, press the Format Options button in the toolbar. Alternatively, right-click the image and select Format options. Format Options menu

To implement the drop-down menu effect in WeChat Mini Programs, specific code examples are required. With the popularity of mobile Internet, WeChat Mini Programs have become an important part of Internet development, and more and more people have begun to pay attention to and use WeChat Mini Programs. The development of WeChat mini programs is simpler and faster than traditional APP development, but it also requires mastering certain development skills. In the development of WeChat mini programs, drop-down menus are a common UI component, achieving a better user experience. This article will introduce in detail how to implement the drop-down menu effect in the WeChat applet and provide practical

Windows accessibility capabilities and features have been slowly growing. The Windows 1122H2 update brings a number of new features, including the ability to use system-wide live subtitles on your system. This is a much-requested feature, especially since other platforms started including it last year. Let us know more about it. What are system-wide live subtitles in Windows 11? As the name suggests, system-wide live subtitles help you generate subtitles for any audio currently playing on your system. This is an important accessibility feature for hearing-impaired users and can also be used to generate subtitles in unsupported applications. You can also use live subtitles to transcribe audio files and create inaudible

With the popularity of web applications, drop-down menus have become a common user interface element. Drop-down menus conveniently provide users with a range of action options, allowing users to easily select the action they want. In modern web applications, Vue has become a popular framework and drop-down menus can be implemented using Vue. In this article, we will introduce how to use Vue to implement drop-down menus, and provide some practical tips and techniques to help you better manage and develop Vue applications. 1. Basic drop-down
