我有以下形式:保留從下拉列表中選擇動態值,但仍然能夠看到名單後提交
<div id="Quick_find_container">
<form action="" method="post" target="_self">
<div id="qcategory_1">Product</div>
<div id="qcategory">
<select name="Category" class="dropmenu" id="Category"onchange="this.form.submit()">
<option value="">Any</option>
<option value="Keyboard"<?php if ($_POST['Category']=="Keyboard") {echo "selected='selected'"; } ?>>Keyboard</option>
<option value="Piano"<?php if ($_POST['Category']=="Piano") {echo "selected='selected'"; } ?>>Piano</option>
</select>
</div>
<div id="qbrand_1">Brand</div>
<div id="qbrand"><select name='Manufacturer' onchange="this.form.submit()">
<?php
echo '<option value="">Any</option>';
$value = $_POST['Manufacturer'];
while ($row = mysql_fetch_array($RS_Search)) {
echo "<option value=" . $row['Manufacturer'] . " ' . (selected == $value ? ' selected' : '') . '>" . $row['Manufacturer'] . "</option>";
}
?>
</select>
</div>
<div id="qsubmit">
<input name="Search2" type="submit" id="Search2" value="Submit">
</div>
</form>
</div>
<?php echo $_POST['Category']; ?>
<?php echo $_POST['Manufacturer']; ?>
後回聲類別和製造商是純粹的,看看它是什麼提交。
我的問題是第二個下拉菜單。我想在選擇某些東西之後顯示所選值。目前它只是跳回到默認值Any,即使POST_ [Manufacturer']的輸出是正確的。 有沒有辦法像第一個下拉菜單中那樣顯示選定的值?我仍然想保留值以從數據庫中選擇。但只顯示選定的值。
任何幫助,歡迎
非常感謝你的訣竅 – Ria