Weird result in PHP form
Posted: Tue Apr 13, 2010 11:12 am
Hi
I'm beginning a form that asks questions and has a drop down list of options to choose from. I'm going to use PHP to check for errors, loops to cut down on repetition, etc., but right now I'm just testing code at a basic level.
Here's the PHP:
Here's the basic form element:
My problem is that the text displayed in the select box is only the first letter of whatever it's supposed to be. For example: if it's the first time visiting the form, each box only has "C" in it instead of "Choose one..." OR if "Does not apply" was chosen and the form is submitted, "D" is all that shows up in that box.
Any idea what's happening here?
Many thanks,
Andy
I'm beginning a form that asks questions and has a drop down list of options to choose from. I'm going to use PHP to check for errors, loops to cut down on repetition, etc., but right now I'm just testing code at a basic level.
Here's the PHP:
Code: Select all
if(isset($_POST['submit'])){
$value[1] = $_POST['choice1'];
$value[2] = $_POST['choice2'];
$value[3] = $_POST['choice3'];
}
else {
$value[1] = 'Choose one...';
$value[2] = 'Choose one...';
$value[3] = 'Choose one...';
}Code: Select all
<select name="choice1">
<option value="0">'.$value[1].'</option>
<option value="Addressed">Addressed</option>
<option value="Does not apply">Does not apply</option>
<option value="Needs attention">Needs attention</option>
</select>Any idea what's happening here?
Many thanks,
Andy