/    Sign up×
Community /Pin to ProfileBookmark

Storing Multiple Selections on Drop Down Menu

This is probably easy, so my ears are reading to learn.

I have a drop down list with seven options. Whatever they pick gets sent to an email address, pretty basic php stuff here.

My problem is the user is selecting more than one of the seven options by clicking ‘shift’ and selecting four or five or all. How can I record this in my php? I would like to keep the drop down menu instead of changing to a different variable for each.

Any gurus can help me out there? Any help would be greatly appreciated.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@SyCoJun 24.2009 — Add this to the forms landing (action) page
[code=php]print_r($_REQUEST);[/code]
and you'll see how the incoming data is structured and should be able to ammend your code to handle it.
Copy linkTweet thisAlerts:
@1234567890authorJun 24.2009 — Thank you. My question is how to amend the code to handle this ? Sorry, n00b here ?
Copy linkTweet thisAlerts:
@SyCoJun 24.2009 — Something like this

[code=php]<?
print_r($_POST);
?>
<form method=post action="#">
<select name="multiple_select[]" multiple>
<option value="red">red</option>
<option value="green">green</option>
<option value="blue">blue</option>
</select>
<input type="submit">
</form>[/code]
Copy linkTweet thisAlerts:
@1234567890authorJun 24.2009 — SyCo, thank you for your patience. I will try this and report back ?

Also, another developer working with Linux. Nice to see ?
Copy linkTweet thisAlerts:
@SyCoJun 24.2009 — [code=php]<?
print_r($_POST);

foreach($_POST as $key =>$value){
if(is_array(@$vaule)){
foreach($value as $key2 =>$value2){
//process array form inputs
//checkboxes can take advantage of this too
}
}else{
//process normal form inputs
}
}

?>
<form method=post action="#">
<select name="multiple_select[]" multiple>
<option value="red">red</option>
<option value="green">green</option>
<option value="blue">blue</option>
</select>
<input type="hidden" name="hideme" value="hidden val">
<input type="submit">
</form>[/code]
Copy linkTweet thisAlerts:
@SyCoJun 24.2009 — SyCo, thank you for your patience. I will try this and report back ?

Also, another developer working with Linux. Nice to see ?[/QUOTE]


Ironically even though I have a *nix heart and was brought up coding on Apache, these days I spend all day on IIS 2008 and MSSQL 5. PHP is as far as my company has gone in to FOSS.

They claim to be a fully windows shop, except for the things like our router software and firewall. You know, little stuff. lol. My Windows to the core boss just had to use bit defender on knoppix to remove a virus. Loi <=on the inside ?

Good luck with the rest of your project.
×

Success!

Help @1234567890 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 5.18,
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,
)...