Yii Framework Forum: [Resolvido]Exibir Outros Dropdowns A Partir Do Valor Do Dropdown Anterior - Yii Framework Forum

Jump to content

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

[Resolvido]Exibir Outros Dropdowns A Partir Do Valor Do Dropdown Anterior Rate Topic: -----

#1 User is offline   assissouza 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 06-February 12

Posted 19 November 2012 - 01:45 PM

Nas informações de cadastro de aluno é solicitada em um dropdown a informação de situacao escolar (estuda | nao estuda), quero que a partir do valor selecionado (estuda), exiba outros três dropdown com escola, turno e serie. Eles não são dependetes um do outro. Quero que funcione tipo aqueles campos de trabalha ou nao trabalha, que apenas no caso de trabalhar pede as informações da empresa.

Attached File  dropdown-help.png (19.94K)
Number of downloads: 19

_form do aluno-----------------------------------
<?php
/* @var $this AlunoController */
/* @var $model Aluno */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'aluno-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<?php $turma=CHtml::listData(Turma::model()->findAll(), 'id','turma', 'horario')?>
	<div class="row">
		<?php echo $form->labelEx($model,'turma'); ?>
		<?php echo $form->dropDownList($model,'turma',$turma); ?>
		<?php echo $form->error($model,'turma'); ?>
	</div>

	<?php $usuario=CHtml::listData(Usuario::model()->findAll(), 'id','nome')?>
	<div class="row">
		<?php echo $form->labelEx($model,'usuario'); ?>
		<?php echo $form->dropDownList($model,'usuario', $usuario); ?>
		<?php echo $form->error($model,'usuario'); ?>
	</div>

	<?php $categoria=CHtml::listData(Catpublico::model()->findAll(), 'id','categoria')?>
	<div class="row">
		<?php echo $form->labelEx($model,'catpublico'); ?>
		<?php echo $form->dropDownList($model,'catpublico', $categoria); ?>
		<?php echo $form->error($model,'catpublico'); ?>
	</div>

	<?php $situacao=CHtml::listData(Sitescolar::model()->findAll(), 'id','situacao')?>
	<div class="row">
		<?php echo $form->labelEx($model,'situa_escolar'); ?>
		<?php echo $form->dropDownList($model,'situa_escolar', $situacao); ?>
		<?php echo $form->error($model,'situa_escolar'); ?>
	</div>
	
	<?php $escola=CHtml::listData(Escola::model()->findAll(), 'id','escola')?>
	<div class="row">
		<?php echo $form->labelEx($model,'escola'); ?>
		<?php echo $form->dropDownList($model,'escola',$escola); ?>
		<?php echo $form->error($model,'escola'); ?>
	</div>

	<?php $turno=CHtml::listData(Turno::model()->findAll(), 'id','turno')?>
	<div class="row">
		<?php echo $form->labelEx($model,'turno'); ?>
		<?php echo $form->dropDownList($model,'turno',$turno); ?>
		<?php echo $form->error($model,'turno'); ?>
	</div>

	<?php $serie=CHtml::listData(Serie::model()->findAll(), 'id','serie')?>
	<div class="row">
		<?php echo $form->labelEx($model,'serie'); ?>
		<?php echo $form->dropDownList($model,'serie',$serie); ?>
		<?php echo $form->error($model,'serie'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->


De já agradeço a quem ajudar-me!
0

#2 User is offline   Gustavo Gonçalves 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 02-October 12
  • Location:Belo Horizonte, MG - Brasil

Posted 20 November 2012 - 06:11 AM

Olá bom dia,

Fiz isso esses dias. Segui essa dica aqui:
http://www.yiiframew...dpost__p__99019

Abs,
0

#3 User is offline   assissouza 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 06-February 12

Posted 23 November 2012 - 02:04 PM

blz fiz algo parecido usando javascript
<script>
function verificaCombo(obj){
  opcao = obj.value;
  if (opcao == "4")//codigo da situacao escolar 4 == nao estuda
  {
  document.forms[0].situa_escolar.disabled = false;
     document.forms[0].escola.disabled = true;
     document.forms[0].turno.disabled = true;
     document.forms[0].serie.disabled = true;
	}
  else
  {
     document.forms[0].escola.disabled = false;
     document.forms[0].turno.disabled = false;
     document.forms[0].serie.disabled = false;
	}
}
</script>

<?php $situacao=CHtml::listData(Sitescolar::model()->findAll(), 'id','situacao')?>
	<div class="row">
		<?php echo $form->labelEx($model,'situa_escolar'); ?>
		<?php echo $form->dropDownList($model,'situa_escolar', $situacao, array('id'=>'situa_escolar','onchange'=>'verificaCombo(this);')); ?>
		<?php echo $form->error($model,'situa_escolar'); ?>
	</div>
	
	<?php $escola=CHtml::listData(Escola::model()->findAll(), 'id','escola')?>
	<div class="row">
		<?php echo $form->labelEx($model,'escola'); ?>
		<?php echo $form->dropDownList($model,'escola',$escola, array('id'=>'escola','onchange'=>'verificaCombo(this);')); ?>
		<?php echo $form->error($model,'escola'); ?>
	</div>

	<?php $turno=CHtml::listData(Turno::model()->findAll(), 'id','turno')?>
	<div class="row">
		<?php echo $form->labelEx($model,'turno'); ?>
		<?php echo $form->dropDownList($model,'turno',$turno, array('id'=>'turno','onchange'=>'verificaCombo(this);')); ?>
		<?php echo $form->error($model,'turno'); ?>
	</div>

	<?php $serie=CHtml::listData(Serie::model()->findAll(), 'id','serie')?>
	<div class="row">
		<?php echo $form->labelEx($model,'serie'); ?>
		<?php echo $form->dropDownList($model,'serie',$serie, array('id'=>'serie','onchange'=>'verificaCombo(this);')); ?>
		<?php echo $form->error($model,'serie'); ?>
	</div>


Vlw pela ajuda amigo!
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