mickeyckm
(Mickeyckm)
April 17, 2010, 6:38am
1
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
Vince
(Vadimg88)
April 17, 2010, 8:29am
2
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
});