Yii Framework Forum: Activedropdown On Change Event - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Activedropdown On Change Event Rate Topic: -----

#1 User is offline   kiranjv 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 10-April 13

Posted 22 April 2013 - 05:18 AM

this is my view:

<?php
$em=EmployerJobs::model()->findAll();
$model = new EmployerJobs();
$list = CHtml::listData($em,'Employer_JobsJobCode','Employer_JobsJobCode');
echo CHtml::activeDropDownList($model,'Employer_JobsJobCode',$list, array('empty' => 'Please Select'));
?>

it's working fine, select making a list of values from table called employerjobs,

now i need to create onchange event for dropdown, if i change value in dropdown it should retrive particular row details.

im newbie on yii, i confused, i seeking for help. TIA
0

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 22 April 2013 - 05:33 AM

/* moved from Miscellaneous */
"Less noise - more signal"
0

#3 User is offline   kiranjv 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 10-April 13

Posted 22 April 2013 - 05:52 AM

[quote name='kiranjv' timestamp='1366625911' post='202253']
this is my view:

<?php
$fa=EmployerJobs::model()->findAll();
$model = new EmployerJobs();
$list = CHtml::listData($fa,'Employer_JobsJobCode','Employer_JobsJobCode');
echo CHtml::activeDropDownList($model,'Employer_JobsJobCode',$list, array('empty' => 'Please Select'
, 'id'=> 'shrtlst_candt_jobcode',
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('Jobaspirant/shortlistCan'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#shrtlst_candt-firstname2', //selector to update
'data'=>"javascript:$('#shrtlst_candt_jobcode option:selected').val();"
//leave out the data key to pass all form values through
)));
?>
it's working fine, select making a list of values from table called employerjobs,

This is my controller


public function actionShortlistCan()
{
$model = new Candidateinterview;
$new_interviews = Candidateinterview::model()->findAllByAttributes(array('AspirantID'=>$model->AspirantID,'ConfirmInterview'=>0));
$model = new EmployerJobs;
$data = EmployerJobs::model()->findAll();
/*'Employer_JobsJobCode',
array($_POST['Employer_JobsJobCode'])*/

$data=CHtml::listData($data,'Employer_JobsJobPos','Employer_JobsJobLoc');
foreach($data as $value=>$name)
{
echo CHtml::tag('h3',
array('value'=>$value),CHtml::encode($name),true);
}
}


if i change value in dropdown it should retrive particular row details.

im newbie on yii, i confused, seeking for any help. TIA
0

#4 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 22 April 2013 - 07:16 AM

View Postkiranjv, on 22 April 2013 - 05:18 AM, said:

this is my view:

<?php
$fa=EmployerJobs::model()->findAll();
$model = new EmployerJobs();
$list = CHtml::listData($fa,'Employer_JobsJobCode','Employer_JobsJobCode');
echo CHtml::activeDropDownList($model,'Employer_JobsJobCode',$list, array('empty' => 'Please Select'
, 'id'=> 'shrtlst_candt_jobcode',
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('Jobaspirant/shortlistCan'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#shrtlst_candt-firstname2', //selector to update
'data'=>"javascript:$('#shrtlst_candt_jobcode option:selected').val();"
//leave out the data key to pass all form values through
)));
?>
it's working fine, select making a list of values from table called employerjobs,

This is my controller


public function actionShortlistCan()
{
$model = new Candidateinterview;
$new_interviews = Candidateinterview::model()->findAllByAttributes(array('AspirantID'=>$model->AspirantID,'ConfirmInterview'=>0));
$model = new EmployerJobs;
$data = EmployerJobs::model()->findAll();
/*'Employer_JobsJobCode',
array($_POST['Employer_JobsJobCode'])*/

$data=CHtml::listData($data,'Employer_JobsJobPos','Employer_JobsJobLoc');
foreach($data as $value=>$name)
{
echo CHtml::tag('h3',
array('value'=>$value),CHtml::encode($name),true);
}
}


if i change value in dropdown it should retrive particular row details.

im newbie on yii, i confused, seeking for any help. TIA


Just have a look at this wikki article
i hope you can get idea where are you doing mistake.
have you seen that function from above given link and compared your function in controller.
public function actionDynamiccities()
{
    $data=Location::model()->findAll('parent_id=:parent_id', 
                  array(':parent_id'=>(int) $_POST['country_id']));
 
    $data=CHtml::listData($data,'id','name');
    foreach($data as $value=>$name)
    {
        echo CHtml::tag('option',
                   array('value'=>$value),CHtml::encode($name),true);
    }
}

just have look into this code and compare it with your once.i hope you will get some difference.
CodeSutra
1

#5 User is offline   kiranjv 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 10-April 13

Posted 22 April 2013 - 11:14 AM

View Postcodesutra, on 22 April 2013 - 07:16 AM, said:

Just have a look at this wikki article
i hope you can get idea where are you doing mistake.
have you seen that function from above given link and compared your function in controller.
public function actionDynamiccities()
{
    $data=Location::model()->findAll('parent_id=:parent_id', 
                  array(':parent_id'=>(int) $_POST['country_id']));
 
    $data=CHtml::listData($data,'id','name');
    foreach($data as $value=>$name)
    {
        echo CHtml::tag('option',
                   array('value'=>$value),CHtml::encode($name),true);
    }
}

just have look into this code and compare it with your once.i hope you will get some difference.


Thanks for your comment...

i got the difference
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users