duandu1915 2017-06-19 04:17 采纳率: 100%
浏览 36

在用户输入时检索数据

I have five text fields in my page and when the user types something in first textfield, I need to retrieve the values based on the first textfield. Right now, I have hardcode the value as 121, which is returning the value properly from DB, but how do I make it dynamic ?

<?php echo $form->textField(emp::model()->findByAttributes(array('id' => '121' )),'empno');  ?> 
  • 写回答

2条回答 默认 最新

  • dongli8979 2017-06-19 04:33
    关注

    You can ajax call for it while typing in the textbox as follows:

    $("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
        }
    
    });
    
    评论

报告相同问题?