<br><div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode15'));"><u>复制代码</u></span></div>代码如下:</div> <div class="msgborder" id="phpcode15"> <br> <br> <br><?php <br />// 获取select值 <br>$select_value = isset($_GET['select']) ? $_GET['select'] : ''; <br>?> <br><form action="?"> <br><select name="select"> <br><option value="">default</option> <br><option value="option1"></option>// 如果在上面获取的值和这个option里的值一样, <br>// 就打印selected,让这个option默认被选中 <br>echo $select_value == 'option1' ? 'selected' : '' <br>?>>option1 <br></select> <br><input type="submit" value="submit"> <br> </form> <br> <br><br> </div> <br>每个选项都要加上这个脚本,如果多个的话可以循环打印。