What blogs can I read?
Drop Down Box Question
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > PHP web-programming > Drop Down Box Question 22 July 2002 01:05:50

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

Drop Down Box Question

Wanda Hansen 21 July 2002 18:43:25
 Hello,
Is there a way to handle data gathered from a drop down menu that allows
multiple selections using PHP?
Thank you,
Julian



--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Jason Stechschulte 21 July 2002 19:18:34 permanent link ]
 On Sun, Jul 21, 2002 at 11:43:25AM -0400, WANDA HANSEN wrote:> Is there a way to handle data gathered from a drop down menu that> allows multiple selections using PHP?

Yes. The way I normally do this is to use HTML that looks something
like:

<select multiple='multiple'­ name='test[]'>
<option value='1'>Red</opti­on>
<option value='2'>Green</op­tion>
<option value='3'>Blue</opt­ion>
</select>

Now in your PHP program, you can access them all with something like:

<?php
foreach($_POST['test'] as $test) {
echo "You selected $test<br />\n";
}
?>

--
Jason Stechschulte
stech@ypisco.com
http://www.ypisco.c­om
--
History books which contain no lies are extremely dull.

--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Chris Wesley 21 July 2002 20:00:37 permanent link ]
 On Sun, 21 Jul 2002, WANDA HANSEN (AKA Julian) wrote:
Is there a way to handle data gathered from a drop down menu that allows> multiple selections using PHP?

Sure ... check out this demo:

http://cwwesley.net­/php/snippets/combob­ox.php

and the source:
http://cwwesley.net­/php/snippets/snip_s­ource.php?show=combo­box.php

g.luck,
~Chris


--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
John Holmes 21 July 2002 20:18:20 permanent link ]
 
Hello,> Is there a way to handle data gathered from a drop down menu that
allows> multiple selections using PHP?

Of course. Name your select box as an array, and include the 'multiple'
keyword.

<select name='something[]' multiple>

Then you'll have an array on your processing page that holds all of the
values that were selected. $_POST['something'][]. Note that it starts at
zero.

You can use count($_POST['something']) to see how many were selected,
etc...

---John Holmes...


--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Richard Lynch 22 July 2002 00:05:50 permanent link ]
 
Hello,>> Is there a way to handle data gathered from a drop down menu that>allows>> multiple selections using PHP?>
Of course. Name your select box as an array, and include the 'multiple'>keyword.­>
<select name='something[]' multiple>>
Then you'll have an array on your processing page that holds all of the>values that were selected. $_POST['something'][]. Note that it starts at>zero. >
You can use count($_POST['something']) to see how many were selected,>etc...

If you need specific IDs or something from the OPTIONs presented, other than
the text between the tags, you can even use the VALUE= attribute to pass
around data so that $_POST['something'] doesn't just start at 0 and count
up:

<?php
while (list($id, $name) = each($ineeddatacapt­ain)){
echo "$id: $name<BR>\n";
}
?>
<SELECT NAME=ineeddatacapta­in[] MULTIPLE SIZE=5>
<OPTION VALUE=1>Captain Kirk</OPTION>
<OPTION VALUE=2>Spock</OPTI­ON>
<OPTION VALUE=3>McCoy</OPTI­ON>
<OPTION VALUE=4>Scotty</OPT­ION>
<OPTION VALUE=5>Sulu</OPTIO­N>
<OPTION VALUE=6>Uhura</OPTI­ON>
<OPTION VALUE=7>Chekov</OPT­ION>
</SELECT>

If you click on Spock, instead of just 0, Spock, you'll get 2, Spock -- You
get his ID number as well as his name.

This is extremely convenient. And you sure can't do that in ASP easily :-)­

--
Like Music? http://l-i-e.com/ar­tists.htm

--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Richard Lynch 22 July 2002 01:05:50 permanent link ]
 
Hello,>> Is there a way to handle data gathered from a drop down menu that>allows>> multiple selections using PHP?>
Of course. Name your select box as an array, and include the 'multiple'>keyword.­>
<select name='something[]' multiple>>
Then you'll have an array on your processing page that holds all of the>values that were selected. $_POST['something'][]. Note that it starts at>zero. >
You can use count($_POST['something']) to see how many were selected,>etc...

If you need specific IDs or something from the OPTIONs presented, other than
the text between the tags, you can even use the VALUE= attribute to pass
around data so that $_POST['something'] doesn't just start at 0 and count
up:

<?php
while (list($id, $name) = each($ineeddatacapt­ain)){
echo "$id: $name<BR>\n";
}
?>
<SELECT NAME=ineeddatacapta­in[] MULTIPLE SIZE=5>
<OPTION VALUE=1>Captain Kirk</OPTION>
<OPTION VALUE=2>Spock</OPTI­ON>
<OPTION VALUE=3>McCoy</OPTI­ON>
<OPTION VALUE=4>Scotty</OPT­ION>
<OPTION VALUE=5>Sulu</OPTIO­N>
<OPTION VALUE=6>Uhura</OPTI­ON>
<OPTION VALUE=7>Chekov</OPT­ION>
</SELECT>

If you click on Spock, instead of just 0, Spock, you'll get 2, Spock -- You
get his ID number as well as his name.

This is extremely convenient. And you sure can't do that in ASP easily :-)­

--
Like Music? http://l-i-e.com/ar­tists.htm
Add comment
John Holmes 22 July 2002 01:39:29 permanent link ]
 
-----Original Message-----> From: Richard Lynch [mailto:rich@phpbootcamp.com]> Sent: Sunday, July 21, 2002 5:06 PM> To: php-general@lists.p­hp.net> Subject: Re: [PHP] Drop Down Box Question>
Hello,> >> Is there a way to handle data gathered from a drop down menu that> >allows> >> multiple selections using PHP?> >
Of course. Name your select box as an array, and include the
'multiple'> >keyword.> >
<select name='something[]' multiple>> >
Then you'll have an array on your processing page that holds all of
values that were selected. $_POST['something'][]. Note that it starts
zero.> >
You can use count($_POST['something']) to see how many were selected,> >etc...>
If you need specific IDs or something from the OPTIONs presented,
other> than> the text between the tags, you can even use the VALUE= attribute to
pass> around data so that $_POST['something'] doesn't just start at 0 and
count> up:>
<?php> while (list($id, $name) = each($ineeddatacapt­ain)){> echo "$id: $name<BR>\n";> }> ?>> <SELECT NAME=ineeddatacapta­in[] MULTIPLE SIZE=5>> <OPTION VALUE=1>Captain Kirk</OPTION>> <OPTION VALUE=2>Spock</OPTI­ON>> <OPTION VALUE=3>McCoy</OPTI­ON>> <OPTION VALUE=4>Scotty</OPT­ION>> <OPTION VALUE=5>Sulu</OPTIO­N>> <OPTION VALUE=6>Uhura</OPTI­ON>> <OPTION VALUE=7>Chekov</OPT­ION>> </SELECT>>
If you click on Spock, instead of just 0, Spock, you'll get 2, Spock
--> You> get his ID number as well as his name.

That's confusing. There's no way to get "Spock" from the code. You only
get the number in the value attribute. If the user were to choose Spock
and McCoy, then you'd have:

$_POST['ineeddatacaptain'][0] --> 2
$_POST['ineeddatacaptain'][1] --> 4

It's up to the programmer to associate 2 with Spock, and 4 with McCoy.

---John Holmes...


--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > PHP web-programming > Drop Down Box Question 22 July 2002 01:05:50

see also:
FLASH AND PHP
Re: multiple SELECT and missing rows.
Snmp, php and Win2K
pass tests:
†...Avatars from Moka...†
see also:
How to convert video to rmvb from Flip…
How to convert flip video to windows…
How to convert flip video to wmv from…

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .