在yii中选择组合值时更改datepicker中的值

在yii中选择组合值时更改datepicker中的值,yii,combobox,datepicker,Yii,Combobox,Datepicker,我有一个表单中的组合框。根据从combo中选择的值,必须在datepicker中更改date的值。如何执行此操作? 代码如下: <div class="row col2"> <?php $records = CHtml::listData(CodeValue::model()->findAll(array('order' => 'code_lbl','condition'=>"code_type= 'visit_type'")), 'code_id',

我有一个表单中的组合框。根据从combo中选择的值,必须在datepicker中更改date的值。如何执行此操作? 代码如下:

    <div class="row col2">
<?php $records = CHtml::listData(CodeValue::model()->findAll(array('order' => 'code_lbl','condition'=>"code_type= 'visit_type'")), 'code_id', 'code_lbl');?>
    <?php echo $form->labelEx($model,'visit_type'); ?>
    <?php echo $form->dropDownList($model,'visit_type',$records,array('empty' => 'Select Visit Type')); ?>
    <?php echo $form->error($model,'visit_type'); ?>
</div>
<div class="row col2">
        <?php echo $form->labelEx($model,'next_visited_date'); ?>
        <?php 
        $this->widget('zii.widgets.jui.CJuiDatePicker',array(
            'model' => $model,
            'attribute'=>'next_visited_date',

            //'flat'=>true,//remove to hide the datepicker
            'options'=>array(
                'showAnim'=>'drop',//'slide','fold','slideDown','fadeIn','blind','bounce','clip','drop'
                'dateFormat' => 'yy-mm-dd',
                'showButtonPanel' => true,      // show button panel
            ),
            'htmlOptions'=>array(
                'style'=>''
            ),
        ));
      ?>
    <?php echo $form->error($model,'next_visited_date'); ?>
    </div>
我必须根据所选的就诊类型更改就诊日期。

您必须使用ajax:

将下拉列表更改为使用ajax,例如:

<?php echo $form->dropDownList($model,'visit_type',$records,array(
                                      'empty' => 'Select Visit Type',
                                      'ajax' => array(
                                      'type'=>'POST',
                                      'url'=>CController::createUrl('controller/myAction'),//your controller and action name
                                      'update'=>'#Model_next_visited_date', //replace Model with the model name
                                      'success'=> 'function(data) {
                                        $("#Model_next_visited_date").empty(); //replace Model with the model name
                                        $("#Model_next_visited_date").val(data); //replace Model with the model name
                                      } '
                                      ))); 
    ?>
希望有帮助

public function actionMyAction()
    {
        //you will receive drop down value in $_POST['Model']['visit_type']
        // Place your date logic here.....
    }