Yii Framework Forum: Creating A Dependant Dropdown Without Database Tables - Yii Framework Forum

Jump to content

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

Creating A Dependant Dropdown Without Database Tables Rate Topic: -----

#1 User is offline   vaijanath 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 09-October 13
  • Location:Bengaluru

Posted 03 July 2014 - 05:06 AM

Hello,
I'm trying to create dependant dropdown without using database tables. And the values will be loaded in the function and returned.In the view, i have set those values in the dropdown. Now the problem is i want to make the sencond dropdown list dependant based on the the value selected in the first drop down.
Here is what i have done till now.
In my Model :
public function getDistrictList(){
return array(
array('key'=>'GLB', 'value'=>'Gulbarga'),
array('key'=>'YG', 'value'=>'Yadgir'),
array('key'=>'BNG', 'value'=>'Bangalore'),
array('key'=>'MSR', 'value'=>'Mysore'),
);
}
public function getTalukList(){
return array(
array('key'=>'BN', 'value'=>'Bangalore North'),
array('key'=>'BS', 'value'=>'Bangalore South'),
array('key'=>'BE', 'value'=>'Bangalore East'),
array('key'=>'ANK', 'value'=>'Anekal'),
array('key'=>'GLB', 'value'=>'Gulbarga'),
array('key'=>'YG', 'value'=>'Yadgir'),
array('key'=>'SDM', 'value'=>'Sedam'),
array('key'=>'CHT', 'value'=>'Chittapur'),
array('key'=>'CHN', 'value'=>'Chincholi'),
array('key'=>'JVG', 'value'=>'Jevargi'),
array('key'=>'MSR', 'value'=>'Mysore'),
);
}

In my view :

<div class="row">
<label for="district"><?php echo CHtml::encode($model->getAttributeLabel('district')); ?></label>
<?php $list = CHtml::listData(Inquiries::model()->getDistrictList(), 'key', 'value'); ?>
<?php echo $form->dropDownList($model, 'district', $list, array('empty'=>'(Select a District)')); ?>
</div>
<div class="row">
<label for="taluq"><?php echo CHtml::encode($model->getAttributeLabel('taluq')); ?></label>
<?php $list = CHtml::listData(Inquiries::model()->getTalukList(), 'key', 'value'); ?>
<?php echo $form->dropDownList($model, 'taluq', $list, array('empty'=>'(Select a Taluk)')); ?>
</div>

Please help me.
0

#2 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 884
  • Joined: 20-April 11
  • Location:India

Posted 03 July 2014 - 07:22 AM

This will help you

http://www.yiiframew...ist-using-ajax/
Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

#3 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 884
  • Joined: 20-April 11
  • Location:India

Posted 03 July 2014 - 07:23 AM

Or this

http://www.yiiframework.com/wiki/24/
Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 03 July 2014 - 08:15 AM

NOTE: moved to proper section (General Discussion for Yii 1.1.x instead of the book section)
Find more about me.... btw. Do you know your WAN IP?
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