Hi,
I am playing with Yii for a few days and so far I am very impressed. I am having fun
At this moment I am playing with dependent dropdown lists, it all works great until the point that I want to get the value of the second drop down.
in my view: (I am working with a textfield instead of a dropdown, the entry will be searched in the database and works flawlessly)
echo CHtml::textField("input_town",'',array('id'=>'input_town','ajax' => array(
'type' =>'POST',
'url' => CController::createUrl('town'),
'update' => '#townlist',
'data' => 'html',
'submit' => '',
'data'=>"js:{input_town: $('#input_town').val()}",
))); ?>
In my controller I have :
public function actionTown() {
$a = $_POST["input_town"];
...
...
looks in database etc.
...
echo CHtml::dropDownList('test','',
array(2=>'test',1=>'Middle Atlantic',3=>'East North Central'),
array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('towna'),
'update'=>'#showing_id',
)));
}
The dropdown is put exactly where I want it to bel And as you see I am trying to put a bit of AJAX in it hoping that it will do the same as the code in my VIEW. However it is not working.
When I check in firebug I see the controller working perfectly when I type text and hit enter. However nothing when I make a selection in my dropdownlist. I also played with ‘onChange’ but also not the desired results.
How do I get the value of the second dropdown?
Thanks in advance,
W.