Why Cann't Get Value From Dropdownlist?

after select C_seat <div> is auto show text, but in the controller cannot get value from dropdownlist

index.php




<div class="control-group">

    <label class="control-label" for="Customers_C_time">

        Time

        <span class="required"> * </span>

    </label>

    <div class="controls">

        <?php

        echo $form->dropDownList($model, 'C_time', $this->HH(), array('empty' => 'select',

            'ajax' => array(

                'type' => 'POST',

                'url' => CController::createUrl('Customers/MM'),

                'update' => '#Customers_drpMinute',

                'data' => array('hour' => 'js:this.value'),

            ), 'class' => 'input-small',

        ));


        echo " : ";


        echo $form->dropDownList($model, 'drpMinute', array('empty' => 'select'), array('class' => 'input-small',));

        echo $form->error($model, 'C_time');

        echo $form->error($model, 'drpMinute');

        ?>

        <div id="error"></div>

    </div>

</div>  

<?php

echo $form->dropDownListRow($model, 'C_seats', $this->getSeat(), array('empty' => 'select',

    'ajax' => array(

        'type' => 'POST',

        'url' => CController::createUrl('Customers/isAvailable'),

        'update' => '#status',

        'data' => array('seats' => 'js:this.value'),

    ), 'class' => 'input-small',

));

?>



Controller.php




public $hr;

public $mm;

public $se;

public function actionisAvailable() {

    if (isset($_POST['seats']) && $_POST['seats'] != '') {

        $this->se = $_POST['seats'];

        $this->hr = $_POST['C_time']; 

        $this->mm = $_POST['drpMinute'];

    }

    echo CHtml::encode(print_r($this->hr, true));

}



if you print_r($_POST); what get value ?

If you are using Yii Framework version >= 1.1.11, then you must use CJavaScriptExpression to add client side script for widgets.

I’ve modified a little bit of your code here, try using this:

index.php




<div class="control-group">

    <label class="control-label" for="Customers_C_time">

        Time

        <span class="required"> * </span>

    </label>

    <div class="controls">

        <?php

        echo $form->dropDownList($model, 'C_time', $this->HH(), array('empty' => 'select',

        	'clientChange' => array(

            	'ajax' => array(

         	       'type' => 'POST',

                	'url' => CController::createUrl('Customers/MM'),

                	'update' => '#Customers_drpMinute',

                	'data' => array('hour' => new CJavaScriptExpression("this.value")),

            	),

			),

   		'class' => 'input-small',

        ));


        echo " : ";


        echo $form->dropDownList($model, 'drpMinute', array('empty' => 'select'), array('class' => 'input-small',));

        echo $form->error($model, 'C_time');

        echo $form->error($model, 'drpMinute');

        ?>

        <div id="error"></div>

    </div>

</div>  

<?php

echo $form->dropDownListRow($model, 'C_seats', $this->getSeat(), array('empty' => 'select',

    'ajax' => array(

        'type' => 'POST',

        'url' => CController::createUrl('Customers/isAvailable'),

        'update' => '#status',

        'data' => array('seats' => new CJavaScriptExpression('this.value')),

    ), 'class' => 'input-small',

));

?>