1 回答
TA贡献1829条经验 获得超9个赞
为了回答你的问题:
$variable='first / second ... '; // one variable
如果您不想IF在同一页面中使用,可以在另一个页面中使用函数:
function HowMuch($variable){
if($variable=='first'){
echo '
<option value="Explore" style="background: #fd7803; color: white;">Explore</option>
<option value="Prompt" style="background: #fdd303; color: white;">Prompt</option>
<option value="Unaided" style="background: #58d95e; color: white;">Unaided</option>
<option value="Mastered" style="background: #12c4f9; color: white;">Mastered</option>
<option value="Not Applicable" style="background: grey; color: black;">Not Applicable</option>';
}elseif($variable=='second '){
echo '
<option value="Prompt" style="background: #fdd303; color: white;">Prompt</option>
<option value="Unaided" style="background: #58d95e; color: white;">Unaided</option>
<option value="Mastered" style="background: #12c4f9; color: white;">Mastered</option>
<option value="Not Applicable" style="background: grey; color: black;">Not Applicable</option>';
}
}
现在 select 所在的页面:
<select name="e1" id="year" class="form-control" required="required">
<option value="" selected="selected" style="background: #0356e8;color: white;">- -</option>
HowMuch($variable); //variable contains first or second..
</select>
- 1 回答
- 0 关注
- 93 浏览
添加回答
举报