Re: Problem with receving selection list values
> <select name="jogos" size="5" multiple id="jogos">[color=blue]
> <option value="1">Battlefield 1942</option>
> <option value="2">Call of Duty</option>
> </select>[/color]
[color=blue]
> The problem is that the variable $_POST['jogos'] only have the last[/color]
option,[color=blue]
> for example if i select Battlefield 1942 (value 1) and Call of Duty (value
> 2) it only have the value 2.
> What i'd like to know is how to get all the values selected from the[/color]
select[color=blue]
> list.[/color]
You need to name select-element like name="jogos[]". And result is then IN
PHP-ARRAY called jogos(not jogos[] ). Programs like Frontpage can complain
about naming elements in this manner, but ignore it. This is only and right
way with php.
BTW, remember also to have something selected as default. I have impression
that different browsers may behave differently if you dont have default
selection and user doesn't choose any option. With database driven systems
<option selected value="0">Choose your jogos</option> is usually good,
because id-values that come fron database are positive integers, not zero.
Or of course value="false" or something else special enought works fine too.
perttu p, finland |