我的页面中有五个文本字段,当用户在第一个文本字段中输入内容时,我需要根据第一个文本字段检索值。现在,我将值硬编码为121,这是从DB正确返回值,但我如何使其动态化?
<?php echo $form->textField(emp::model()->findByAttributes(array('id' => '121' )),'empno'); ?>
答案 0 :(得分:0)
您可以在文本框中键入时调用它,如下所示:
$("textbox").on('keyup',function(){
// use get or post request here to retrieve the data
$.post('url',{parameters},function(data){
//code to set the data in you UI
}
});
答案 1 :(得分:0)
使用Yii的内置自动完成小部件。它基于jQuery UI库。
http://www.yiiframework.com/doc/api/1.1/CJuiAutoComplete
$this->widget('zii.widgets.jui.CJuiAutoComplete',array(
'name'=>'city',
'sourceUrl'=> "<your keyword suggestion url here>",
// additional javascript options for the autocomplete plugin
'options'=>array(
'minLength'=>'2',
),
));