user1722138
user1722138

Reputation:

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>

Upvotes: 0

Views: 400

Answers (1)

user1722138
user1722138

Reputation:

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..

Upvotes: 1

Related Questions