<select name="type_of_room" style="color:#fefefe; background-color:#2C3E50;">
<option selected="selected" value="0">...Choose Type Of Room...</option>
<option value="1">Special_Room</option>
<option value="2" >Single_Room</option>
<option value="3" >Dual_Room</option>
<option value="4" >Triple_Room </option>
</select> <input type="submit" name="show_detail" value="Show Detail" style="margin: 20px; background-color: #f2dede;"/>
单击按钮时不保存我的选择
答案 0 :(得分:0)
试试这个:
<?php
$selectedValue = '0';
if(isset($_GET['type_of_room'])) {
$selectedValue = $_GET['type_of_room'];
}
?>
<select name="type_of_room" style="color:#fefefe; background-color:#2C3E50;">
<option <?php if($selectedValue == '0'): ?>selected="selected"<?php endif; ?> value="0">...Choose Type Of Room...</option>
<option <?php if($selectedValue == '1'): ?>selected="selected"<?php endif; ?> value="1">Special_Room</option>
<option <?php if($selectedValue == '1'): ?>selected="selected"<?php endif; ?> value="2" >Single_Room</option>
<option <?php if($selectedValue == '3'): ?>selected="selected"<?php endif; ?> value="3" >Dual_Room</option>
<option <?php if($selectedValue == '4'): ?>selected="selected"<?php endif; ?> value="4" >Triple_Room </option>
</select>