1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>选项框</title> 6 </head> 7 <body> 8 //select选项示例 9 <select> 10 <option>Volvo</option> 11 <option selected="selected">Saab</option> 12 <option>Mercedes</option> 13 <option>Audi</option> 14 </select> 15 16 17 //原生混编写法选项框,$GET获取参数 18 <div class="form-group"> 19 <label class="col-sm-2 control-label">运营意见</label> 20 <div class="col-sm-8"> 21 <select class="form-control input-sm" name="yy_opinion" id="yy_opinion"> 22 <option value="0">请选择</option> 23 <?php foreach ($yy_opinion_data as $k => $v): ?> 24 <option value="<?php echo $k; ?>" 25 <?php if (!empty($GET['yy_opinion']) && $GET['yy_opinion']== $k): ?> 26 selected=selected 27 <?php endif ?> 28 ><?php echo $v; ?></option> 29 <?php endforeach; ?> 30 </select> 31 </div> 32 </div> 33 34 35 //laravel5.6模板写法 36 <div class="form-group"> 37 <label>游戏名称</label> 38 <select class="form-control input-sm" name="sdk_game_id" id="sdk_game_id"> 39 <option value=""> 请选择游戏名称</option> 40 @foreach($game_name as $k => $item) 41 <option value="{{$k}}" @if (!empty($_GET['sdk_game_id']) && $_GET['sdk_game_id']== $k) selected=selected @endif > 42 {{$item}} 43 </option> 44 @endforeach 45 </select> 46 </div> 47 48 </body> 49 </html>