简体   繁体   中英

How to retain option value in select drop down

Using what I have, this will display the drop down box with a blank entry at the top, in Firefox, if I refresh the page, the selected value will appear, no such luck in IE, how can I tweak this to get the selected value to appear without refreshing the page?

<tr>
<td align="right">Department:</td>
<td align="left"><select name="department" width="145" style="width: 145px">
<option selected value="<?php echo $row['department'];?>"/></option>
<option value="Pack House">Pack House</option>
<option value="Picking">Picking</option>
<option value="Pick Tower">Pick Tower</option>
<option value="QA">QA</option>
<option value="Receiving">Receiving</option>
<option value="Replen">Replen</option>
<option value="Shipping">Shipping</option>
<option value="IT">IT</option>
<option value="Loaned">Loaned</option>
</select>
</tr>

I was able to find a working solution

<td align="right">Department:</td>
  <td align="left"><select name="department" width="145" style="width: 145px">
<option<?php if ($row['department'] == "Pack House"): ?> selected="selected"<?php endif; ?>>Pack House</option>
<option<?php if ($row['department'] == "Picking"): ?> selected="selected"<?php endif; ?>>Picking</option>
<option<?php if ($row['department'] == "Pick Tower"): ?> selected="selected"<?php endif; ?>>Pick Tower</option>
<option<?php if ($row['department'] == "QA"): ?> selected="selected"<?php endif; ?>>QA</option>
<option<?php if ($row['department'] == "Receiving"): ?> selected="selected"<?php endif; ?>>Receiving</option>
<option<?php if ($row['department'] == "Replen"): ?> selected="selected"<?php endif; ?>>Replen</option>
<option<?php if ($row['department'] == "Shipping"): ?> selected="selected"<?php endif; ?>>Shipping</option>
<option<?php if ($row['department'] == "IT"): ?> selected="selected"<?php endif; ?>>IT</option>
<option<?php if ($row['department'] == "Loaned"): ?> selected="selected"<?php endif; ?>>Loaned</option>
</select>
<tr>

Thank you to the one person who commented..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM