Connecting Tech Pros Worldwide Help | Site Map

Problem with receving selection list values

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:58 AM
João Proença
Guest
 
Posts: n/a
Default Problem with receving selection list values

Ok the problem is this, when i try to receve the values from a form with the
selection list below:

<select name="jogos" size="5" multiple id="jogos">
<option value="1">Battlefield 1942</option>
<option value="2">Call of Duty</option>
</select>

The problem is that the variable $_POST['jogos'] only have the last option,
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 select
list.



Thx in advance,
João Proença



  #2  
Old July 17th, 2005, 04:58 AM
Perttu Pulkkinen
Guest
 
Posts: n/a
Default 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




 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.