posting a multiple select

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Vantuykom
Forum Newbie
Posts: 19
Joined: Fri Jul 04, 2003 6:22 am

posting a multiple select

Post by Vantuykom »

:cry:
I'm having a little problem, in my form, I have to select multiple lines in a 'select' field and post it for processing.

Now in the $_POST-variable, there is only the last selected item visible.

How can I post every selected line?

thanx a lot
jollyjumper
Forum Contributor
Posts: 107
Joined: Sat Jan 25, 2003 11:03 am

Post by jollyjumper »

Hi Vantuykom,

Try something like this(the name with the []):
<select multiple name="myname[]">
.....
</select>

You should receive an array in php now, instead of the last item.

Greetz Jolly.
Vantuykom
Forum Newbie
Posts: 19
Joined: Fri Jul 04, 2003 6:22 am

Post by Vantuykom »

thanx a lot :D
jollyjumper
Forum Contributor
Posts: 107
Joined: Sat Jan 25, 2003 11:03 am

Post by jollyjumper »

You're welcome, btw you can do this with more form fields than a multiple select. You can also insert multiple textboxes with myname[] and it will be an array in php. But a disadvantage about this method is that you can't use document.forms['myform'].myname.value anymore. A workaround for this is giving the textbox an id and use document.getElementById

Greetz Jolly.
Post Reply