Forums
This topic is locked
menus/lists
Posted 09 Oct 2001 17:06:12
1
has voted
09 Oct 2001 17:06:12 Keith Slater posted:
Hey.. Im trying to make a list of a bunch of different things to choose from and I want to be able to select multiple ones. When they select more then one and submit it it only submits one and not all the ones I select.. Whats the easiest way to do that?? thanks!!!
Keith Slater
Replies
Replied 09 Oct 2001 17:55:06
09 Oct 2001 17:55:06 Tim Green replied:
Keith your post is a little ambiguous, please can you be a bit clearer ?
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 09 Oct 2001 19:14:55
09 Oct 2001 19:14:55 Keith Slater replied:
hmm ok let me try hehe...
I have a list box with like 15 different things to pick from. They can pick multiple things from the list box also. THe problem I'm having is when they select multiple options from the box it only submits one. I know it can be done because I've seen it.
thanks again
Keith Slater
I have a list box with like 15 different things to pick from. They can pick multiple things from the list box also. THe problem I'm having is when they select multiple options from the box it only submits one. I know it can be done because I've seen it.
thanks again
Keith Slater
Replied 09 Oct 2001 22:16:38
09 Oct 2001 22:16:38 Bruno Mairlot replied:
Keith,
it is normal, since when you post your form, only one of the selected value are passed.
So you must set up a JavaScript that will concatenate all the selected value of your <select> into a hidden input that will contain the real value, then you submit the form with JavaScript.
In your PHP code, you will explode() your hidden value into an array that will contains all the values the user selected.
Hope it helps.
If you need more info, post your code and let's have a look.
Bruno
"First they laugh at you, then they fight you, then you Win..." Ghandi
it is normal, since when you post your form, only one of the selected value are passed.
So you must set up a JavaScript that will concatenate all the selected value of your <select> into a hidden input that will contain the real value, then you submit the form with JavaScript.
In your PHP code, you will explode() your hidden value into an array that will contains all the values the user selected.
Hope it helps.
If you need more info, post your code and let's have a look.
Bruno
"First they laugh at you, then they fight you, then you Win..." Ghandi
Replied 09 Oct 2001 23:03:57
09 Oct 2001 23:03:57 Keith Slater replied:
Ah ok I see what your saying will I be able to do delimited stuff with it like put comas between each selection then return it delimited or anything like that??
Here is one of the <select>'s
<select tabindex="16" name="inside" size=5 multiple>
<option value="Air Conditioning">Air conditioning </option>
<option value="Basement">Basement </option>
<option value="Cable Ready">Cable ready </option>
<option value="Central Air">Central Air </option>
<option value="Dishwasher">Dishwasher </option>
<option value="Disposer">Disposer </option>
<option value="Eat in Kitchen">Eat in kitchen </option>
<option value="Eating Area">Eating area </option>
<option value="Elavator">Elevator </option>
<option value="Family Room">Family Room </option>
<option value="Fire Place">Fire Place </option>
<option value="Forced Air Heating">Forced air heating </option>
<option value="Formal Dining Room">Formal dining room </option>
<option value="Handicapped Accessible">Handicapped accessible </option>
<option value="Hardwood Floors">Hardwood floors </option>
<option value="Laundry Room">Laundry room in building </option>
<option value="Master Bedroom">Master Bedroom </option>
<option value="Microwave">Microwave </option>
<option value="Paid Utilities">Paid utilities </option>
<option value="Pets Allowed">Pets allowed </option>
<option value="Security System">Security system </option>
<option value="Storage Space">Storage space </option>
<option value="Washer/Dryer">Washer/dryer in unit </option>
<option value="Workshop">Workshop </option>
</select>
Keith Slater
Here is one of the <select>'s
<select tabindex="16" name="inside" size=5 multiple>
<option value="Air Conditioning">Air conditioning </option>
<option value="Basement">Basement </option>
<option value="Cable Ready">Cable ready </option>
<option value="Central Air">Central Air </option>
<option value="Dishwasher">Dishwasher </option>
<option value="Disposer">Disposer </option>
<option value="Eat in Kitchen">Eat in kitchen </option>
<option value="Eating Area">Eating area </option>
<option value="Elavator">Elevator </option>
<option value="Family Room">Family Room </option>
<option value="Fire Place">Fire Place </option>
<option value="Forced Air Heating">Forced air heating </option>
<option value="Formal Dining Room">Formal dining room </option>
<option value="Handicapped Accessible">Handicapped accessible </option>
<option value="Hardwood Floors">Hardwood floors </option>
<option value="Laundry Room">Laundry room in building </option>
<option value="Master Bedroom">Master Bedroom </option>
<option value="Microwave">Microwave </option>
<option value="Paid Utilities">Paid utilities </option>
<option value="Pets Allowed">Pets allowed </option>
<option value="Security System">Security system </option>
<option value="Storage Space">Storage space </option>
<option value="Washer/Dryer">Washer/dryer in unit </option>
<option value="Workshop">Workshop </option>
</select>
Keith Slater
Replied 09 Oct 2001 23:29:13
09 Oct 2001 23:29:13 Bruno Mairlot replied:
Yes sure,
as long as there isn't any comma into the <select> values you can use comma.
When doing this, I usually use | since it is a very rare character, so it doesn't pose any problems.
--- Better to die trying, than never try at all ---
as long as there isn't any comma into the <select> values you can use comma.
When doing this, I usually use | since it is a very rare character, so it doesn't pose any problems.
--- Better to die trying, than never try at all ---
Replied 10 Oct 2001 14:57:05
10 Oct 2001 14:57:05 Keith Slater replied:
ok cool. How would I do the | thing then?? Also do you know where I can find a sample of that javascript??
Thanks a lot!!!
Keith Slater
Thanks a lot!!!
Keith Slater
Replied 10 Oct 2001 14:59:37
10 Oct 2001 14:59:37 chief monkey replied:
You can recieve multiple values from a form object with PHP first a few things you must add for example your opening tag would be
<select name="yourname[]" multiple>
The brakets ([]) tell PHP to expect an array, the mutiple tag lets the user select more than one option.
Once submited you can treat it like any other array i.e
if (is_array($yourname)) {
echo"Your form values<br>";
while(list($key, $value) = each($yourname))
{
echo $value . "<br>\n";
}
}
Everybody has got to be somewhere