I have:
General Question
Company Information
Customer Issue
Supplier Issue
Request For Quote
Other
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):
Name:*So, any ideas for drop downs?
解决方案
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:
$options = array( 1=>'General Question', 'Company Information', 'Customer Issue', 'Supplier Issue', 'Supplier Issue', 'Request For Quote', 'Other' );
$topic = $_REQUEST['topic']; // the topic name would now be $options[$topic]
// other PHP etc...
?>
<?php foreach ( $options as $i=>$opt ) : ?>
><?php echo $opt ?>