Hi guys , im trying to make a form with a drop down list that when selected a javascript generate another form, but i dont know how to do it , i looked at google and here and found nothing, could some one help me on how to do it in yii??
Hi guys , im trying to make a form with a drop down list that when selected a javascript generate another form, but i dont know how to do it , i looked at google and here and found nothing, could some one help me on how to do it in yii??
Do it with javascript jquery… onchange event do ajax call, call a controller to return a renderPartial view and update the layer with another form.
How can i do this do you have an example ?
Here is what you need: http://www.bitrepository.com/dynamic-dependant-dropdown-list-us-states-counties.html
But for the "yii way" you need to know basics, Antonio gave you the algorithm.
<div class="form">
<script>
$("select").change(function () {
alert('worked');
});
</script>
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'imagens-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->dropDownList($model,'imagem',array('1','121','3')); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
isnt working =/
Because <script> needs to be behind <select>… Or put:
$(document).ready(function() {
// Handler for .ready() called.
});