我需要在表单提交后回显 selected =“selected”。
echo '<form id="myform1" class="myform1" method="GET" name="myform1">';
echo '<select id="SortBy" name="SortBy" onchange="return submitForm1()">';
echo '<option value="" disabled="disabled">Order By</option>';
echo '<option value="RegularPrice">Price</option>';// if selected echo selected="selected"
echo '<option value="MaxGuests">Max Guests</option>';// if selected echo selected="selected"
echo '</select>';
echo '</form>';
任何想法?
答案 0 :(得分:0)
<?php
echo '<option value="RegularPrice"';
if (isset($_GET['SortBy']) AND $_GET['SortBy'] == 'RegularPrice') {
echo ' selected="selected"';
}
echo '>Price</option>';
?>