echo CHtml::dropDownList(‘UsersStatsInfo’,’’, array(1=>‘height’,2=>‘weight’,3=>‘chest’),
array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('usersStatsInfo/myGraph'), //url to call.
'update'=>'#td-id', //selector to update
)));
Hi,here use the Property data as shown below,
array(
'ajax' => array(
'type'=>'POST', //request type
'data'=>array('userstatus'=>$this.value()),
'url'=>CController::createUrl('usersStatsInfo/myGraph'), //url to call.
'update'=>'#td-id', //selector to update
)
In Controller:
if(isset($_POST['userstatus']))
{
$user_status = $_POST['userstatus'];//here u will receive the respective height/width based on the selection then u can exceute the query and render the page
}
i think Devendra411 cant solve his problem this way, that i said!! requirement is not clear atall!!
I’m getting Undefined index:id
my viewl
<?php
echo CHtml::dropDownList('id','', array(1=>'height',2=>'weight',3=>'chest',4=>'waist',5=>'hips',6=>'biceps',7=>'bmi'),
array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('graph'), //url to call.
'update'=>'#td_id', //selector to update
//'data'=>'js:javascript statement'
)));
?>
controller
public function actionGraph() {
$model = new UsersStatsInfo();
$data=UsersStatsInfo::model()->findAll('id=:id',
array(':id'=>(int) $_POST['id']));
$data=CHtml::listData($data,'loginId','height');
foreach($data as $value=>$height)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($height),true);
}
$this->render('graph', array('model'=>$model));
}
And my db screen shot i’m attaching below. I need to dispaly db values based on drop down.
public function actionGraph() {
echo 'test';exit;
$model = new UsersStatsInfo();
$data=UsersStatsInfo::model()->findAll('id=:id',
array(':id'=>(int) $_POST['id']));
$data=CHtml::listData($data,'loginId','height');
foreach($data as $value=>$height)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($height),true);
}
$this->render('graph', array('model'=>$model));
}
see whats happening
its displaying only "test"