I have:
<select name="topic" style="margin-bottom:3px;">
<option>General Question</option>
<option>Company Information</option>
<option>Customer Issue</option>
<option>Supplier Issue</option>
<option>Request For Quote</option>
<option>Other</option>
</select>
for the drop down. And when the form is submitted, It goes to a validation page. If it has errors the form keeps the original content the user put in. I have it working for all of the input fields and textarea's, but how could I do this with a drop down?
I have the input fields staying by using:
$name = $_REQUEST["name"];
and in the form that shows up again, there is (ignore the fact that it is in a table):
<tr>
<td>Name:*</td>
</tr>
<tr>
<td><input name="name" type="text" size="15" value="<?php echo $name ?>" maxlength="200" /></td>
</tr>
So, any ideas for drop downs?
First of all, give the option element a value attribute. This makes the code more robust, because it does not break should you decide to alter the text of an option. After that:
You need to add the "selected" attribute to the appropriate option. I believe you also need to specify the value attribute for each option. I don't know exactly how you are generating that list, but maybe this will help: