How to set value to dropdown list
Posted on 2009-05-16
I'm new at php. I'm trying to create form that uses some dropdown menu/lists to let the user choose between a handful options. There are also quite a few text fields on the form.
Everything works perfect as long as the user fills in all the fields en lists. When the users clicks on 'submit' without filling in all text boxes en lists, I want to show exactly the same form as it was before pressing the 'submit' button.
This works perfect for all my text boxes, but all lists are reset.
I have collected the values of all contents in the dropdown lists with
$rubriek = $_POST["rubriek"];
$rubriek2 = $_POST["rubriek2"];
When a submit failed, echo $rubriek; shows the correct choice of the user, but the dropdown list shows the first option again.
How can I set the value of the dropdown list to $rubriek??
I tried things like
form.rubriek.text = $rubriek;
but that doesn't do anything.