比如当前PHP计算所得周次是第10周,那么HTML的SELECT控件应该默认选择10,且下拉选项还有1-25的值供选。
不知道怎么弄简单点,我现在用很傻的办法, 结合了JQ,有没有简洁点的方法?jQuery("#stpointstemp-week").val('<?=$weekly?>');/*页面载入后设置当前周次*/
<?= $form->field($model, 'week')->dropDownList(['1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9','10'=>'10',
'11'=>'11','12'=>'12','13'=>'13','14'=>'14','15'=>'15','16'=>'16','17'=>'17','18'=>'18','19'=>'19','20'=>'20',
'21'=>'21','22'=>'22','23'=>'23','24'=>'24','25'=>'25'
]) ?>
<?php $model->week = $weekly; ?>
在前面加上这句代码 <?php $model->week = $weekly; ?>