Reputation: 1131
I have these two input types:
The first one:
echo "<input type='radio' name='tipo_campo' value='$enum_array[$i]' required>" . ' ' .$enum_array[$i] . '<br>';
if I do:
echo $_POST['tipo_campo'];
It will display the correct value.
But for this:
echo "<option name='tipo_unid' value='$tipo_unidade[0]'>". $tipo_unidade[1] ."</option>";
the
echo $_POST['tipo_unid'];
Will be empty.
I have tested the $tipo_unidade[0] separately, and it has the correct value, so I know that's not the problem.
Why does the first POST display the correct value, and the second one is empty?
Thanks for your time!
Upvotes: 1
Views: 297
Reputation: 520
For option we should not use name there we are only supposed to give value name has to give in the select tag
For example
<select name="xxx">
<option value="1">one</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
Sure this will helps you
Upvotes: 1
Reputation: 1574
try this
<select name="tipo_unid">
<option value=<?=$tipo_unidade[0];?>><?=$tipo_unidade[1];?></option>
</select>
print_r($_POST); or echo $_POST['tipo_unid'];
Upvotes: 0
Reputation: 163
usage:
<select name="option">
<option value="1" selected>First</option>
<option value="2">Second</option>
</select>
post/get
echo $_POST['option'];
output:
1
Upvotes: 1