Home > php教程 > PHP源码 > body text

Yii -AutoComplete 表单自动提示实例

WBOY
Release: 2016-06-08 17:23:33
Original
1151 people have browsed it

本文章来给各位同学介绍Yii -AutoComplete 表单自动提示实例,有需要了解的同学可进入参考。

<script>ec(2);</script>


CJuiAutoComplete 在用户输入时可以根据用户输入的前几个字符自动提示用户可以输入的文字。它封装了 JUI autocomplete插件。

基本用法如下:


controller层代码:

——————————————-

 代码如下 复制代码

class SiteController extends Controller

{

 public function actionIndex()

 {

 $data=array(‘Nanjing’, ‘Beijing’, ‘Perth’,

‘Chicago’,'Paris’,'Pengnai’,'Sydney’);

 $this->render(‘index’, array(

 ‘data’ => $data,

 ));

 }

}


view层代码:

——————————————————

 代码如下 复制代码

$this->widget(‘zii.widgets.jui.CJuiAutoComplete’, array(

‘name’=>’city’,

’source’=>$data,

‘options’=>array(

 ‘minLength’=>’1′,//设置文本框中有最少有几个字符的时候开始提示

 ),

 ‘htmlOptions’=>array(

 ’style’=>’height:20px;’

 ),

));

?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!