Dropdownlist

Could anyone viewing this, please help me figure out how to achieve this implementation. I got a model that has a dropdownlist. When a value is selected from the dropdownlist, one textarea in the same model should be outo-populated with data from a table. have Been trying to achieve it for days but no success. here is the model extends CFormModel


 true, 			//'attributes'=>array('id'=>'survey'), 			'elements'=>array( 			'<h2>Business firm name<hr></h2>', 				'business_firm_name'=>array('hint'=>'Enter a single business name here'), 				'

<h2>Busiess mailing address<hr></h2>', 				'postal_address'=>array(), 				'postal_code'=>array('hint'=>'hint:00200'), 				'fax'=>array(), 				'email'=>array(), 				'structure'=>array( 					'type'=>'dropdownlist', 					'items'=>array( 						'----------Select---------', 						'Soleproprietor'=>'Soleproprietor', 						'Corporation'=>'Corporation', 						'Limited Partnership'=>'Limited Partnership', 					     					) 				), 				'amount'=>array(), 			     				'city'=>array( 					'type'=>'dropdownlist', 					'items'=>array( 						'----------Select---------', 						'Nairobi'=>'Nairobi', 						'Mombasa'=>'Mombasa', 						'Kisumu'=>'Kisumu', 					     					) 				), 			     				'

<h2>Business operation information<hr></h2>', 				'First date of business at this location for this ownership structure', 			     				'month'=>array( 				     					'type'=>'dropdownlist', 					'items'=>array( 						'----------Select---------', 						'Jan'=>'Jan', 						'Feb'=>'Feb', 						'March'=>'March', 						'April'=>'April', 						'May'=>'May', 						'June'=>'June', 						'July'=>'July', 						'August'=>'August', 						'Sep'=>'Sep', 						'October'=>'October', 						'Nov'=>'Nov', 						'Dec'=>'Dec', 					     					     					) 				), 			     				'year'=>array(), 				'activity'=>array( 					'type'=>'checkbox', 					'items'=>array('wholesale'=>'wholesale'),/*  ,'2'=>'retail','3'=>'manufacturing','4'=>'services' */ 				     					'hint'=>'Indicate the business activity(s) you carry out.'),  		         'description'=>array('type'=>'textarea','hint'=>'Describe in  details the principle product(s) or service(s) you provide'), 			     			), 			'buttons'=>array( 				'previous'=>array( 					'type'=>'submit', 					'label'=>'Previous' 				), 				'submit'=>array( 					'type'=>'submit', 					'label'=>'Next' 				), 				'save_draft'=>array( 					'type'=>'submit', 					'label'=>'Save' 				) 			) 		), $this); 	} } 

The table structure resembles one below id----------type-----------------------------amount 1… soleproprietor…100000 2…Corporation…200000 3…Limited Partnership…400000 So what am trying to achieve is, when i select the option for soleproprietor in the model for instance, the textarea labeled amount should be populated wth 100000. Please help me and thanks in advance.

Hi,

maybe there’s a better way to solve this, but you could try something similar as:

http://www.yiiframework.com/wiki/24/creating-a-dependent-dropdown

In your case, instead of populate possible values of the 2nd dropdown, you just have to set its value.