/    Sign up×
Community /Pin to ProfileBookmark

Problems in recieving posted multi selection box.

Hi,

Hi have a multi selection box, more then one item is selected and the form is posted to the next page.

Now the problem is that I only have the last item selected on the new page.

How do I recieve the posted multi select box data on the nuw page? ?

Could somebody please help me.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@DJsACSep 03.2006 — the value should be an array.

<input type=multiselectthing name="multi">

etc..

$multi = $_REQUEST['multi'];

$selection1 = $multi[0];

$selection2 = $multi[1];

$selection3 = $multi[2];

$selection4 = $multi[3];

etc...
Copy linkTweet thisAlerts:
@NogDogSep 03.2006 — the value should be an array.

<input type=multiselectthing name="multi">

etc..

$multi = $_REQUEST['multi'];

$selection1 = $multi[0];

$selection2 = $multi[1];

$selection3 = $multi[2];

$selection4 = $multi[3];

etc...
[/QUOTE]


You need to give the SELECT element a name ending in "[]", then PHP will create an array of values:

<i>
</i>&lt;form action="handler.php" method="post"&gt;
&lt;select name="foo[]" multiple="multiple"&gt;

Then in your PHP form-handler, in this example the selected values would be available in the $_POST['foo'] array, with $_POST['foo'][0] being the first item selected, etc.
Copy linkTweet thisAlerts:
@DJsACSep 03.2006 — You need to give the SELECT element a name ending in "[]", then PHP will create an array of values:
<i>
</i>&lt;form action="handler.php" method="post"&gt;
&lt;select name="foo[]" multiple="multiple"&gt;

Then in your PHP form-handler, in this example the selected values would be available in the $_POST['foo'] array, with $_POST['foo'][0] being the first item selected, etc.[/QUOTE]

erm yeah :rolleyes: ^^ what he said...

*crawls back under his rock*
×

Success!

Help @gogelpot spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...