这可能是个愚蠢的问题,但我不知道......
<div class="row">
<?php echo $form->labelEx($stmodel,'student_track_class_branch',array('class'=>'col-md-4 control-label')); ?>
<div class="col-md-4">
<?php
$start_class=Yii::app()->user->getState('start_class');
$end_class=Yii::app()->user->getState('end_class');
$std_arr=array();
for($i=$start_class; $i <= $end_class; $i++)
$std_arr[$i]=$i.' Std';
echo $form->dropdownlist($stmodel,'student_track_class_branch',
$std_arr,
array( 'empty'=>'--Select--',
'class'=>'form-control',
'required'=>"required",
'ajax'=>array('type'=>'POST',
'url'=>CController::createUrl('common/UpdateSectionView'),
'data'=>array('std_id'=>'js:$(this).val()','YII_CSRF_TOKEN' => Yii::app()->request->csrfToken),
'update'=>'#StudentTracker_student_track_sec_dept'
)
)
);
?>
<?php echo $form->error($stmodel,'student_track_class_branch'); ?>
</div>
</div>
<div class="row">
<?php echo $form->labelEx($stmodel,'student_track_sec_dept',array('class'=>'col-md-4 control-label')); ?>
<div class="col-md-4">
<?php
$sec_arr=array();
if(!empty($stmodel->student_track_class_branch))
{
$sec=new SchoolSectionDetails;
$sec_avl = $sec->get_section_limit( Yii::app()->user->role, Yii::app()->user->id, $stmodel->student_track_class_branch);
$sec_arr = array();
if (!empty($sec_avl))
{
for ($i = 1; $i <= $sec_avl; $i++)
$sec_arr[$i] = $this->_school_sec[$i];
}
}
echo $form->dropdownlist($stmodel,'student_track_sec_dept',$sec_arr,
array('empty'=>'--Select--','class'=>'form-control','required'=>"required",));
?>
<?php echo $form->error($stmodel,'student_track_sec_dept'); ?>
</div>
</div>
<div class="row">
<?php echo $form->labelEx($model,'test_type',array('class'=>'col-md-4 control-label')); ?>
<div class="col-md-4">
<?php echo $form->dropdownlist($model, 'test_type', $this->_test_type,
array( 'empty'=>'--Select--',
'class'=>'form-control',
'ajax'=>array('type'=>'POST',
'url'=>$this->createUrl('MarkDetails/CreateTestView'),
'data'=>?,
'update'=>'#detail'
)
)
); ?>
<?php echo $form->error($model,'test_type'); ?>
</div>
</div>
选择test_type我需要通过ajax发送student_track_class_branch的值作为test_type中的数据,如果有人知道如何传递这个值,请在这里帮助我。
答案 0 :(得分:0)
如果默认情况下生成,您可以手动指定下拉列表ID并使用它或使用[[CHtml :: activeId()]]获取它。因此,要获得另一个下拉值,您只需要这个
'data'=> array( 'std_id' => 'js:$("#'.CHtml::activeId($stmodel,'student_track_class_branch').'").val()'
答案 1 :(得分:0)
<?php echo $form->dropdownlist($model, 'test_type', $this->_test_type,
array( 'empty'=>'--Select--',
'class'=>'form-control',
'ajax'=>array('type'=>'POST',
'url'=>$this->createUrl('MarkDetails/CreateTestView'),
'data'=>'js:$("#StudentTracker_student_track_class_branch").val()',
'update'=>'#detail'
)
)
); ?>
试试这个。