Ajax and dropDownList

I have spent hours trying to research this with little findings. I am simply trying to get this example to work: http://www.yiiframew…oc/cookbook/24/

I've set everything up, and as I watch the requests, I notice that this code is passing nothing to my controllers allotted method. the parent_id is not being sent. I've researched ajax in the api and there are only 2 parameters that don't seem to do it for me.

however I have gotten somewhere, if I hard code my value in the url it does work for that hardcoded value. For instance

my view:

    <?php echo CHtml::dropDownList('Gen1','',CHtml::listData($typeItem,'id','title'),


        array(


            'ajax'=> array(


                'type'=>'POST',


                'url'=>CController::createUrl('item/updateGen&Gen1=7'),


                'update'=>'#Gen2',


            )


        ));


    


    echo CHtml::dropDownList('Gen2','', array());?>

and my Controller method:

        public function actionUpdateGen()


        {


           $data=ItemType::model()->findAll('master_id=:master_id',


               array(':master_id'=>(int) $_GET['Gen1']));





           $data=CHtml::listData($data,'id','title');


           foreach($data as $value=>$title)


           {


                echo CHtml::tag('option',


                   array('value'=>$value),CHtml::encode($title),true);


               


           }


        }

I had to change the query line to use Get method but it works for that one id. However i need it to dynamically pull the IDs. I tried               

‘url’=>CController::createUrl(‘item/updateGen&Gen1=$this->id’),

and nothing.

Any help would be vastly appreciated

If you are using POST, then 'Get' selection should be available in $_POST. If you are using GET, you need to write some js code to grab the current selection.

do you mean change $data=ItemType::model()->findAll('master_id=:master_id',


               array(':master_id'=>(int) $_POST['Get']))


If not, i don't really know what your saying.

'url'=>CController::createUrl('item/updateGen&Gen1=7'),

Or?

'url'=>Yii::app()->createUrl('item/updateGen', array('Gen1'=>'7')),

They both work correctly, but the point is I don't want to hardcode that 7, i want it to pull it from the options or $typeItem, basically whatever is selected from that drop down needs to be sent to the ajax function which then populates the second drop down with options specific to the first.

This example says it is possible http://www.yiiframew…oc/cookbook/24/ I have just been unable to replicate it’s success. When I use the POST method, I just get an error saying the index Gen1 can not be found. $_POST[‘Gen1’]

Have you wrapped your dropDownList in a form?

<?php echo Chtml::beginForm();


echo CHtml::dropDownList('Gen1','', //...


//...


echo Chtml::endForm();  


?>

You sir, are my hero. I knew it was something small I just could not figure it out.