Yii Framework Forum: JS DropDown - Yii Framework Forum

Jump to content

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

JS DropDown Rate Topic: -----

#1 User is offline   mickeyckm 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 25-March 10

Posted 17 April 2010 - 01:38 AM

Hi everyone,

I was wondering how do you create a dropdown list with an option "Create a new type" and when it is selected, it will shows a textbox on the side. Can it be done with CActiveForm?

e.g.
<?php echo $form->dropDownList($model, 'vendor_id', $vendor_list) ?>


How can I attached javascript on it? OR I can't rely on the ActiveForm anymore and need to list down all the HTML code myself?

Thanks a lot.

Cheers,
Mickey
0

#2 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 17 April 2010 - 03:29 AM

You can pass a third parameter to the dropDownlist fuction that will hold it's id/class something like:

<?php echo $form->dropDownList($model, 'vendor_id', $vendor_list, array('class'=>'vendorIDdropDown')) ?>


Then just use Jquery event 'change' on that class to capture the event and load new content based on the selection. Something like this:


$('.vendorIDdropDown').change(function() {
  // Run ajax callback to load data based on the selection
});

Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
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