Yii Framework Forum: [Solved] How to create dependent DropDown Lists - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[Solved] How to create dependent DropDown Lists Rate Topic: -----

#21 User is offline   shani 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 14-December 12

Posted 18 December 2012 - 04:04 PM

I want to change the contents of dropdownlist on the bases of other dropdownlist

I have 3 tables fst doctor , 2nd timeslot & 3rd appointment
I have the form in appointment in which i use
My code did not work properly

one dropdownlist is

<div class="row">
<?php echo $form->labelEx($model,'doctor_id'); ?>
<?php $doc = CHtml::listData(Doctor::model()->findAll(),'doctor_id','name');
echo $form->DropDownList($model,'doctor_id',$doc,
array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('Appiontment/Slots'),
'update'=>'#'.CHtml::activeId($model,'slot_id')
)));
?>
<?php echo $form->error($model,'doctor_id');?>
</div>

other dropdownlist is which contents are dynamically changed

<div id="row">
<?php echo $form->labelEx($model,'slot_id'); ?>
<?php echo $form->dropDownList($model,'slot_id',array()); ?>
<?php echo $form->error($model,'slot_id'); ?>
</div>




In my appointment controller I use a function

public function actionSlots()
{
$doc_id = $_POST['Doctor']['doctor_id'];
$data = TimeSlot::model()->findAll('doctor_id=:doctor_id',
array(':doctor_id'=>$doc_id));
$data = CHtml::listData($data,'slot_id','timeslot');
foreach($data as $value=>$slot)
{
echo CHtml::tag('option',
array('value'=>$value),

CHtml::encode($slot),true);
}
}

I want to use timeslot of selected doctor in my appointment



Any one Any suggestion??
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • 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