Yii Framework Forum: Ajaxbutton Action Dependant On Dropdown Selection - Yii Framework Forum

Jump to content

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

Ajaxbutton Action Dependant On Dropdown Selection Rate Topic: -----

#1 User is offline   StuartMc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 24-April 13

Posted 24 April 2013 - 03:06 AM

How do you pass a drop down selected value as an action in an ajaxButton?

Below is how I pass as a value, however I would like to pass the selected value from the drop down as the action name

<?php
echo CHtml::ajaxButton(Yii::t('default','Run'),
$this->createUrl('dynamics/run'),
array(
'type'=>'POST',
'data'=> array(
'avalue'=>'js: $("#dropdownlist1 option:selected").val()',
),
'update'=>'#div1-html',
)
);
?>

I tried the following but it doesn't work

<?php
echo CHtml::ajaxButton(Yii::t('default','Run'),
$this->createUrl('dynamics/'.'js: $("#dropdownlist1 option:selected").val()'),
array(
'type'=>'POST',
'update'=>'#div1-html',
)
);
?>
0

#2 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 166
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 24 April 2013 - 03:44 AM

try this one
<?php
 echo CHtml::ajaxButton(
  // Lable of ajax button
  'Ajax Button Request',
  // Request function in controller of yii
  array('site/create'),
  //Parameter with ajax request
  array(
    'data'=>array(
     'value'=>'js:$("#dropdownlist1").val()',
    ),
   'type'=>'POST',  
   'update'=>'#update_selector'   
   ) 
); ?>

0

#3 User is offline   StuartMc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 24-April 13

Posted 24 April 2013 - 06:53 AM

View Postmbala, on 24 April 2013 - 03:44 AM, said:

try this one
<?php
 echo CHtml::ajaxButton(
  // Lable of ajax button
  'Ajax Button Request',
  // Request function in controller of yii
  array('site/create'),
  //Parameter with ajax request
  array(
    'data'=>array(
     'value'=>'js:$("#dropdownlist1").val()',
    ),
   'type'=>'POST',  
   'update'=>'#update_selector'   
   ) 
); ?>



I'm not sure how this makes any difference. Doesn't this just call the 'create' action in 'site' controller. I want to be able to pass the value as the name of the action and not hard code it.
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